Zelda Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2023-03-18 18:24:01
Exec Total Coverage
Lines: 11952 18410 64.9%
Functions: 249 321 77.6%
Branches: 10130 19840 51.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 //--------------------------------------------------------
3 //--------------------------------------------------------
4 // Zelda Classic
5 // by Jeremy Craner, 1999-2000
6 //
7 // hero.cpp
8 //
9 // Hero's class: HeroClass
10 // Handles a lot of game play stuff as well as Hero's
11 // movement, attacking, etc.
12 //
13 //--------------------------------------------------------
14
15 #ifndef __GTHREAD_HIDE_WIN32API
16 #define __GTHREAD_HIDE_WIN32API 1
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 #endif //prevent indirectly including windows.h
18
19 #include "precompiled.h" //always first
20
21 #include <string.h>
22 #include <set>
23 #include <stdio.h>
24
25 #include "hero.h"
26 #include "guys.h"
27 #include "subscr.h"
28 #include "zc_subscr.h"
29 #include "decorations.h"
30 #include "gamedata.h"
31 #include "zc_custom.h"
32 #include "title.h"
33 #include "ffscript.h"
34 #include "drawing.h"
35 #include "combos.h"
36 #include "base/zc_math.h"
37 #include "user_object.h"
38 #include "slopes.h"
39 extern FFScript FFCore;
40 extern word combo_doscript[176];
41 extern byte itemscriptInitialised[256];
42 extern HeroClass Hero;
43 extern ZModule zcm;
44 extern zcmodule moduledata;
45 extern refInfo playerScriptData;
46 #include "zscriptversion.h"
47 #include "particles.h"
48 #include <fmt/format.h>
49 #include "zc/render.h"
50
51 extern refInfo itemScriptData[256];
52 extern refInfo itemCollectScriptData[256];
53 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
54 extern int32_t item_collect_stack[256][MAX_SCRIPT_REGISTERS];
55 extern refInfo *ri; //= NULL;
56 extern int32_t(*stack)[MAX_SCRIPT_REGISTERS];
57 extern byte dmapscriptInitialised;
58 extern word item_doscript[256];
59 extern word item_collect_doscript[256];
60 extern portal* mirror_portal;
61 using std::set;
62
63 extern int32_t skipcont;
64
65 extern int32_t draw_screen_clip_rect_x1;
66 extern int32_t draw_screen_clip_rect_x2;
67 extern int32_t draw_screen_clip_rect_y1;
68 extern int32_t draw_screen_clip_rect_y2;
69 extern word global_wait;
70 extern bool player_waitdraw;
71 extern bool dmap_waitdraw;
72 extern bool passive_subscreen_waitdraw;
73 extern bool active_subscreen_waitdraw;
74
75 int32_t hero_count = -1;
76 int32_t hero_animation_speed = 1; //lower is faster animation
77 static int32_t z3step = 2;
78 29 static zfix hero_newstep(1.5);
79 29 static zfix hero_newstep_diag(1.5);
80 bool did_scripta=false;
81 bool did_scriptb=false;
82 bool did_scriptl=false;
83 byte lshift = 0;
84 int32_t dowpn = -1;
85 int32_t directItem = -1; //Is set if Hero is currently using an item directly
86 int32_t directItemA = -1;
87 int32_t directItemB = -1;
88 int32_t directItemX = -1;
89 int32_t directItemY = -1;
90 int32_t directWpn = -1;
91 int32_t whistleitem=-1;
92 extern word g_doscript;
93 extern word player_doscript;
94 extern word dmap_doscript;
95 extern word passive_subscreen_doscript;
96 extern int32_t script_hero_cset;
97
98 void playLevelMusic();
99
100 extern particle_list particles;
101
102 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
103
104 #define CANFORCEFACEUP (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
105 #define NO_GRIDLOCK (get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
106 #define SWITCHBLOCK_STATE (switchblock_z<0?switchblock_z:(switchblock_z+z+fakez < 0 ? zslongToFix(2147483647) : switchblock_z+z+fakez))
107 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_bit(quest_rules,qr_BROKEN_Z3_ANIMATION))
108
109 1833 bool item_error()
110 {
111
2/2
✓ Branch 0 taken 1809 times.
✓ Branch 1 taken 24 times.
1833 if(QMisc.miscsfx[sfxERROR])
112 1809 sfx(QMisc.miscsfx[sfxERROR]);
113 1833 return false;
114 }
115 14519025 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
116 {
117
2/2
✓ Branch 0 taken 12627 times.
✓ Branch 1 taken 14506398 times.
14519025 if(check_new_slope(x, y+1, 16, 16, oldx, oldy) < 0) return true;
118 14506398 return false;
119 14519025 }
120
121 4845198 static inline bool platform_fallthrough(bool doslopecheck = true)
122 {
123
5/6
✓ Branch 0 taken 4845198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4839160 times.
✓ Branch 3 taken 6038 times.
✓ Branch 4 taken 4834643 times.
✓ Branch 5 taken 4517 times.
13351928 return (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0))
124
2/2
✓ Branch 0 taken 593403 times.
✓ Branch 1 taken 587365 times.
4845198 || (getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
125
6/6
✓ Branch 0 taken 3662981 times.
✓ Branch 1 taken 4256384 times.
✓ Branch 2 taken 339528 times.
✓ Branch 3 taken 4504221 times.
✓ Branch 4 taken 312157 times.
✓ Branch 5 taken 27371 times.
1180768 || (Hero.jumping < 0 && getInput(btnDown, false, get_bit(quest_rules,qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK)!=0) && get_bit(quest_rules,qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS));
126 }
127
128 static inline bool on_sideview_solid(int32_t x, int32_t y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
129 {
130 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16, (slopesmisc == 3)) < 0) return true;
131 if(slopesmisc == 2) return false;
132 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
133 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
134 if (platform_fallthrough() && !ignoreFallthrough) return false;
135 if(slopesmisc != 1 && check_slope(x, y+1, 16, 16) < 0) return true;
136 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
137 return true;
138 return false;
139 }
140
141 7216301 static inline bool on_sideview_solid_oldpos(int32_t x, int32_t y, int32_t oldx, int32_t oldy, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
142 {
143
4/4
✓ Branch 0 taken 1805541 times.
✓ Branch 1 taken 5410760 times.
✓ Branch 2 taken 1774611 times.
✓ Branch 3 taken 30930 times.
7216301 if(slopesmisc != 1 && check_new_slope(x, y+1, 16, 16, oldx, oldy, (slopesmisc == 3)) < 0) return true;
144
2/2
✓ Branch 0 taken 127017 times.
✓ Branch 1 taken 7058354 times.
7185371 if(slopesmisc == 2) return false;
145
4/4
✓ Branch 0 taken 4995307 times.
✓ Branch 1 taken 2063047 times.
✓ Branch 2 taken 149543 times.
✓ Branch 3 taken 4845764 times.
7058354 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
146
6/6
✓ Branch 0 taken 35099 times.
✓ Branch 1 taken 4810665 times.
✓ Branch 2 taken 1790 times.
✓ Branch 3 taken 33309 times.
✓ Branch 4 taken 1224 times.
✓ Branch 5 taken 566 times.
4845764 if (y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true;
147
4/4
✓ Branch 0 taken 1488 times.
✓ Branch 1 taken 4843710 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 1278 times.
4845198 if (platform_fallthrough() && !ignoreFallthrough) return false;
148
4/4
✓ Branch 0 taken 749105 times.
✓ Branch 1 taken 4094815 times.
✓ Branch 2 taken 747875 times.
✓ Branch 3 taken 1230 times.
4843920 if (slopesmisc != 1 && check_new_slope(x, y + 1, 16, 16, oldx, oldy) < 0) return true;
149
6/6
✓ Branch 0 taken 1370776 times.
✓ Branch 1 taken 3471914 times.
✓ Branch 2 taken 1362022 times.
✓ Branch 3 taken 8754 times.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 1362009 times.
4842690 if (y%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
150 8767 return true;
151 4833923 return false;
152 7216301 }
153
154
155 14902589 bool usingActiveShield(int32_t itmid)
156 {
157
2/2
✓ Branch 0 taken 12786527 times.
✓ Branch 1 taken 2116062 times.
14902589 switch(Hero.action) //filter allowed actions
158 {
159 case none: case walking: case rafting:
160 case gothit: case swimhit:
161 12786527 break;
162 2116062 default: return false;
163 }
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12786527 times.
12786527 if(itmid < 0)
165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12786527 times.
12786527 itmid = (Hero.active_shield_id < 0
166 12786527 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
167
2/2
✓ Branch 0 taken 11458423 times.
✓ Branch 1 taken 1328104 times.
12786527 if(itmid < 0) return false;
168
1/2
✓ Branch 0 taken 11458423 times.
✗ Branch 1 not taken.
11458423 if(!checkitem_jinx(itmid)) return false;
169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11458423 times.
11458423 if(!(itemsbuf[itmid].flags & ITEM_FLAG9)) return false;
170 if(!isItmPressed(itmid)) return false;
171 return (checkbunny(itmid) && checkmagiccost(itmid));
172 14902589 }
173 9244425 int32_t getCurrentShield(bool requireActive)
174 {
175
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9244425 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9244425 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
176 return Hero.active_shield_id;
177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9244425 times.
9244425 if(!requireActive) return current_item_id(itype_shield);
178 return -1;
179 9244425 }
180 89157 int32_t getCurrentActiveShield()
181 {
182 89157 int32_t id = Hero.active_shield_id;
183
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 89157 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
89157 if(id > -1 && usingActiveShield(id))
184 return id;
185 89157 return -1;
186 89157 }
187 5152193 int32_t refreshActiveShield()
188 {
189 5152193 int32_t id = -1;
190
2/2
✓ Branch 0 taken 4992436 times.
✓ Branch 1 taken 159757 times.
5152193 if(DrunkcBbtn())
191 {
192 159757 itemdata const& dat = itemsbuf[Bwpn&0xFFF];
193
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 159757 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
159757 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
194 {
195 id = Bwpn&0xFFF;
196 }
197 159757 }
198
3/4
✓ Branch 0 taken 5152193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4659906 times.
✓ Branch 3 taken 492287 times.
5152193 if(id < 0 && DrunkcAbtn())
199 {
200 492287 itemdata const& dat = itemsbuf[Awpn&0xFFF];
201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 492287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
492287 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
202 {
203 id = Awpn&0xFFF;
204 }
205 492287 }
206
3/4
✓ Branch 0 taken 5152193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5152168 times.
✓ Branch 3 taken 25 times.
5152193 if(id < 0 && DrunkcEx1btn())
207 {
208 25 itemdata const& dat = itemsbuf[Xwpn&0xFFF];
209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
210 {
211 id = Xwpn&0xFFF;
212 }
213 25 }
214
3/4
✓ Branch 0 taken 5152193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5151053 times.
✓ Branch 3 taken 1140 times.
5152193 if(id < 0 && DrunkcEx2btn())
215 {
216 1140 itemdata const& dat = itemsbuf[Ywpn&0xFFF];
217
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1140 if(dat.family == itype_shield && (dat.flags & ITEM_FLAG9))
218 {
219 id = Ywpn&0xFFF;
220 }
221 1140 }
222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5152193 times.
5152193 if(!usingActiveShield(id))
223 5152193 return -1;
224 return id;
225 5152193 }
226 static bool is_immobile()
227 {
228 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
229 return false;
230 zfix rate(Hero.steprate);
231 int32_t shieldid = getCurrentActiveShield();
232 if(shieldid > -1)
233 {
234 itemdata const& shield = itemsbuf[shieldid];
235 if(shield.flags & ITEM_FLAG10) //Change Speed flag
236 {
237 zfix perc = shield.misc7;
238 perc /= 100;
239 if(perc < 0)
240 perc = (perc*-1)+1;
241 rate = (rate * perc) + shield.misc8;
242 }
243 }
244 return rate != 0;
245 }
246
247 10359614 bool nomove_action(int action)
248 {
249
2/2
✓ Branch 0 taken 10045132 times.
✓ Branch 1 taken 314482 times.
10359614 switch(action)
250 {
251 case gothit:
252 case drowning:
253 case lavadrowning:
254 case sidedrowning:
255 case falling:
256 case freeze:
257 case sideswimfreeze:
258 case scrolling:
259 case casting:
260 case sideswimcasting:
261 case landhold1:
262 case landhold2:
263 case waterhold1:
264 case waterhold2:
265 case sidewaterhold1:
266 case sidewaterhold2:
267 case hopping:
268 case inwind:
269 314482 return true;
270 }
271 10045132 return false;
272 10359614 }
273
274 5340347 bool HeroClass::isStanding(bool forJump)
275 {
276
3/4
✓ Branch 0 taken 5336910 times.
✓ Branch 1 taken 3437 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5336910 times.
5340347 if(z || fakez) return false;
277
4/4
✓ Branch 0 taken 266519 times.
✓ Branch 1 taken 5070391 times.
✓ Branch 2 taken 428 times.
✓ Branch 3 taken 129520 times.
5466858 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)
278
4/6
✓ Branch 0 taken 129948 times.
✓ Branch 1 taken 136571 times.
✓ Branch 2 taken 129948 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129948 times.
✗ Branch 5 not taken.
266519 && !ladderx && !laddery && !getOnSideviewLadder())
279 129520 return false;
280
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 5207354 times.
5207390 if(hoverclk) return false;
281
2/2
✓ Branch 0 taken 155575 times.
✓ Branch 1 taken 5051779 times.
5207354 if(nomove_action(action)) return false;
282 5051779 int32_t val = check_pitslide();
283
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5051768 times.
5051779 if(val == -2) return false;
284
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 5051753 times.
5051768 if(val == -1) return true;
285 15 return forJump;
286 5340347 }
287 26191 bool HeroClass::isLifting()
288 {
289
2/2
✓ Branch 0 taken 502 times.
✓ Branch 1 taken 25689 times.
26191 if(lift_wpn) return true;
290 25689 return false;
291 26191 }
292
293 39808 void HeroClass::set_respawn_point(bool setwarp)
294 {
295
2/2
✓ Branch 0 taken 33423 times.
✓ Branch 1 taken 6385 times.
39808 if(setwarp)
296 {
297 6385 warpx = x;
298 6385 warpy = y;
299 6385 raftwarpx = x;
300 6385 raftwarpy = y;
301 6385 }
302
2/2
✓ Branch 0 taken 14588 times.
✓ Branch 1 taken 25220 times.
39808 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
303 {
304
2/2
✓ Branch 0 taken 23904 times.
✓ Branch 1 taken 1316 times.
25220 switch(action)
305 {
306 case none: case walking:
307 23904 break;
308 default:
309 1316 return; //Not a 'safe action'
310 }
311
4/6
✓ Branch 0 taken 23904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23904 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 23885 times.
23904 if(z > 0 || fakez > 0 || hoverclk) return; //in air
312
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 23884 times.
23885 if(check_pitslide(true) != -1) return; //On a pit
313
314 { //Check water
315 23884 int32_t water = 0;
316 23884 int32_t types[4] = {0};
317 23884 int32_t x1 = x+4, x2 = x+11,
318 23884 y1 = y+9, y2 = y+15;
319
1/2
✓ Branch 0 taken 23884 times.
✗ Branch 1 not taken.
23884 if (get_bit(quest_rules, qr_SMARTER_WATER))
320 {
321
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 23863 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
23886 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
322
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 19 times.
21 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
323
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
324 2 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
325 23884 }
326 else
327 {
328 types[0] = COMBOTYPE(x1,y1);
329
330 if(MAPFFCOMBO(x1,y1))
331 types[0] = FFCOMBOTYPE(x1,y1);
332
333 types[1] = COMBOTYPE(x1,y2);
334
335 if(MAPFFCOMBO(x1,y2))
336 types[1] = FFCOMBOTYPE(x1,y2);
337
338 types[2] = COMBOTYPE(x2,y1);
339
340 if(MAPFFCOMBO(x2,y1))
341 types[2] = FFCOMBOTYPE(x2,y1);
342
343 types[3] = COMBOTYPE(x2,y2);
344
345 if(MAPFFCOMBO(x2,y2))
346 types[3] = FFCOMBOTYPE(x2,y2);
347
348 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
349 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
350 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
351
352 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
353 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
354 water = typec;
355 }
356
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 23882 times.
23884 if(water > 0)
357 {
358 2 return;
359 }
360 } //End check water
361
362 119410 int poses[4] = {
363 23882 COMBOPOS(x,y+(bigHitbox?0:8)),
364 23882 COMBOPOS(x,y+15),
365 23882 COMBOPOS(x+15,y+(bigHitbox?0:8)),
366 23882 COMBOPOS(x+15,y+15)
367 };
368
2/2
✓ Branch 0 taken 94621 times.
✓ Branch 1 taken 23553 times.
118174 for(auto pos : poses)
369 {
370
2/2
✓ Branch 0 taken 94292 times.
✓ Branch 1 taken 329 times.
94621 if(HASFLAG_ANY(mfUNSAFEGROUND, pos)) //"Unsafe Ground" flag touching the player
371 329 return;
372 }
373 23553 }
374 38141 respawn_x = x;
375 38141 respawn_y = y;
376 38141 respawn_scr = currscr;
377 38141 respawn_dmap = currdmap;
378 39808 }
379
380 14 void HeroClass::go_respawn_point()
381 {
382 14 x = respawn_x;
383 14 y = respawn_y;
384 14 can_mirror_portal = false; //incase entry is on a portal!
385 14 warpx=x;
386 14 warpy=y;
387 14 raftwarpx = x;
388 14 raftwarpy = y;
389 14 trySideviewLadder(); //Cling to ladder automatically
390
391
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
14 if(get_bit(quest_rules, qr_OLD_RESPAWN_POINTS))
392 12 return; //No cross-screen return
393
394
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(currdmap != respawn_dmap || currscr != respawn_scr)
395 {
396 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr,
397 -1, -1, 0, 0, warpFlagNOSTEPFORWARD|warpFlagDONTKILLMUSIC, -1);
398 }
399 14 }
400
401 9446 void HeroClass::trySideviewLadder()
402 {
403
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9446 if(canSideviewLadder() && !on_sideview_solid_oldpos(x,y,old_x,old_y))
404 setOnSideviewLadder(true);
405 9446 }
406
407 23504831 bool HeroClass::can_pitfall(bool ignore_hover)
408 {
409
27/30
✓ Branch 0 taken 22887507 times.
✓ Branch 1 taken 617324 times.
✓ Branch 2 taken 22705911 times.
✓ Branch 3 taken 181596 times.
✓ Branch 4 taken 22699373 times.
✓ Branch 5 taken 6538 times.
✓ Branch 6 taken 22699373 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 22699353 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 22699353 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 70 times.
✓ Branch 13 taken 22699283 times.
✓ Branch 14 taken 22691328 times.
✓ Branch 15 taken 8025 times.
✓ Branch 16 taken 22690461 times.
✓ Branch 17 taken 867 times.
✓ Branch 18 taken 22689439 times.
✓ Branch 19 taken 1022 times.
✓ Branch 20 taken 22609199 times.
✓ Branch 21 taken 80240 times.
✓ Branch 22 taken 22197852 times.
✓ Branch 23 taken 411347 times.
✓ Branch 24 taken 22197572 times.
✓ Branch 25 taken 280 times.
✓ Branch 26 taken 22197572 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1408 times.
✓ Branch 29 taken 22196164 times.
23504831 return (!(isSideViewGravity()||action==rafting||z>0||fakez>0||fall<0||fakefall<0||(hoverclk && !ignore_hover)||inlikelike||inwallm||pull_hero||toogam||(ladderx||laddery)||getOnSideviewLadder()||drownclk||!(moveflags & FLAG_CAN_PITFALL)));
410 }
411
412 2982319 int32_t HeroClass::DrunkClock()
413 {
414 2982319 return drunkclk;
415 }
416 void HeroClass::setDrunkClock(int32_t newdrunkclk)
417 {
418 drunkclk=newdrunkclk;
419 }
420
421 int32_t HeroClass::StunClock()
422 {
423 return lstunclock;
424 }
425 void HeroClass::setStunClock(int32_t v)
426 {
427 lstunclock=v;
428 }
429
430 81665049 int32_t HeroClass::BunnyClock()
431 {
432 81665049 return lbunnyclock;
433 }
434 void HeroClass::setBunnyClock(int32_t v)
435 {
436 lbunnyclock=v;
437 }
438
439
9/18
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 29 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 29 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 29 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 29 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 29 times.
✗ Branch 17 not taken.
87 HeroClass::HeroClass() : sprite()
440 58 {
441 29 lift_wpn = nullptr;
442
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 init();
443 29 }
444
445 //2.6
446
447 //Stop the subscreen from falling. -Z
448
449 643 bool HeroClass::stopSubscreenFalling(){
450 643 return preventsubscreenfalling;
451 }
452
453 void HeroClass::stopSubscreenFalling(bool v){
454 preventsubscreenfalling = v;
455 }
456
457
458 //Set the button items by brute force
459
460 void HeroClass::setAButtonItem(int32_t itmslot){
461 game->awpn = itmslot;
462 }
463
464 void HeroClass::setBButtonItem(int32_t itmslot){
465 game->bwpn = itmslot;
466 }
467
468 5152513 void HeroClass::ClearhitHeroUIDs()
469 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
470 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
471 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
472 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
473 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
474 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
475 //clear it on the next frame, but that had the SAME outcome.
476 //Where and how can I clear a value at the end of every frame, so that:
477 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
478 // 2. FFCs can read it before Waitframe. --same.
479 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
480
2/2
✓ Branch 0 taken 41220104 times.
✓ Branch 1 taken 5152513 times.
46372617 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED_PLAYER; q++ )
481 {
482 /*
483 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
484 {
485 //Z_scripterrlog("frame is: %d\n", frame);
486 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
487 lastHitBy[q][0] = 0;
488 }
489 */
490 41220104 lastHitBy[q][0] = 0;
491 41220104 }
492 5152513 }
493
494 11072 void HeroClass::sethitHeroUID(int32_t type, int32_t screen_index)
495 {
496 11072 lastHitBy[type][0] = screen_index;
497 11072 }
498
499 2929 int32_t HeroClass::gethitHeroUID(int32_t type)
500 {
501 2929 return lastHitBy[type][0];
502 }
503
504 void HeroClass::set_defence(int32_t type, int32_t v)
505 {
506 defence[type] = v;
507 }
508
509 int32_t HeroClass::get_defence(int32_t type)
510 {
511 return defence[type];
512 }
513
514
515 //Set Hero;s hurt sfx
516 void HeroClass::setHurtSFX(int32_t sfx)
517 {
518 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
519 }
520 5692 int32_t HeroClass::getHurtSFX()
521 {
522 5692 return QMisc.miscsfx[sfxHURTPLAYER];
523 }
524
525 bool HeroClass::getDiagMove()
526 {
527 return diagonalMovement;
528 }
529 void HeroClass::setDiagMove(bool newdiag)
530 {
531 diagonalMovement=newdiag;
532 }
533 9024 bool HeroClass::getBigHitbox()
534 {
535 9024 return bigHitbox;
536 }
537 248 void HeroClass::setBigHitbox(bool newbigHitbox)
538 {
539 248 bigHitbox=newbigHitbox;
540 248 syofs = bigHitbox?0:8;
541 248 sysz_ofs = bigHitbox?0:-8;
542 248 }
543 5424 int32_t HeroClass::getStepRate()
544 {
545 5424 return steprate;
546 }
547 void HeroClass::setStepRate(int32_t newrate)
548 {
549 steprate = newrate;
550 }
551 int32_t HeroClass::getSwimUpRate()
552 {
553 return game->get_sideswim_up();
554 }
555 void HeroClass::setSwimUpRate(int32_t newrate)
556 {
557 game->set_sideswim_up(newrate);
558 }
559 int32_t HeroClass::getSwimSideRate()
560 {
561 return game->get_sideswim_side();
562 }
563 void HeroClass::setSwimSideRate(int32_t newrate)
564 {
565 game->set_sideswim_side(newrate);
566 }
567 int32_t HeroClass::getSwimDownRate()
568 {
569 return game->get_sideswim_down();
570 }
571 void HeroClass::setSwimDownRate(int32_t newrate)
572 {
573 game->set_sideswim_down(newrate);
574 }
575
576
577 //void HeroClass::herostep() { lstep = lstep<(BSZ?27:11) ? lstep+1 : 0; }
578 3717523 void HeroClass::herostep()
579 {
580
2/2
✓ Branch 0 taken 3399591 times.
✓ Branch 1 taken 317932 times.
3717523 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
581 //need to run all global/hero/dmap scripts here?
582 3717523 }
583
584 66023 bool is_moving()
585 {
586
6/6
✓ Branch 0 taken 53306 times.
✓ Branch 1 taken 12717 times.
✓ Branch 2 taken 39760 times.
✓ Branch 3 taken 13546 times.
✓ Branch 4 taken 16813 times.
✓ Branch 5 taken 22947 times.
66023 return DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight();
587 }
588
589 // called by ALLOFF()
590 10565 void HeroClass::resetflags(bool all)
591 {
592 10565 refilling=REFILL_NONE;
593 10565 inwallm=false;
594 10565 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
595 10565 usecounts.clear();
596
597
4/4
✓ Branch 0 taken 10526 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 10432 times.
10565 if(swordclk>0 || all)
598 {
599 133 swordclk=0;
600 133 verifyAWpn();
601 133 }
602
4/4
✓ Branch 0 taken 10557 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 10463 times.
10565 if(itemclk>0 || all)
603 102 itemclk=0;
604
605
2/2
✓ Branch 0 taken 10471 times.
✓ Branch 1 taken 94 times.
10565 if(all)
606 {
607 94 NayrusLoveShieldClk=0;
608
609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(nayruitem != -1)
610 {
611 stop_sfx(itemsbuf[nayruitem].usesound);
612 stop_sfx(itemsbuf[nayruitem].usesound+1);
613 }
614
615 94 nayruitem = -1;
616 94 hoverclk=jumping=0;
617 94 hoverflags = 0;
618 94 }
619 10565 damageovertimeclk = 0;
620 10565 newconveyorclk = 0;
621 10565 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
622
2/2
✓ Branch 0 taken 10565 times.
✓ Branch 1 taken 73955 times.
84520 for(auto q = 0; q < 7; ++q)
623 73955 hooked_undercombos[q] = -1;
624 10565 hopclk=0;
625 10565 hopdir=-1;
626 10565 attackclk=0;
627 10565 stomping=false;
628 10565 reset_swordcharge();
629 10565 diveclk=drownclk=drownCombo=0;
630 10565 action=none; FFCore.setHeroAction(none);
631 10565 conveyor_flags=0;
632 10565 magiccastclk=0;
633 10565 magicitem=-1;
634 10565 }
635
636 //Can use this for Hero->Stun. -Z
637 7562 void HeroClass::Freeze()
638 {
639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7562 times.
7562 if (action != inwind)
640 {
641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7562 times.
7562 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
642 7562 else {action=freeze; FFCore.setHeroAction(freeze);}
643 // also cancel Hero's attack
644 7562 attackclk = 0;
645 7562 }
646 7562 }
647 870 void HeroClass::unfreeze()
648 {
649
3/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 388 times.
✓ Branch 2 taken 482 times.
✗ Branch 3 not taken.
870 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
650
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 870 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
870 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
651 870 }
652
653 11 void HeroClass::Drown(int32_t state)
654 {
655 // Hero should never drown if the ladder is out
656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(ladderx+laddery)
657 return;
658
659 11 drop_liftwpn();
660
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 switch(state)
661 {
662 case 1:
663 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
664 attackclk=0;
665 attack=wNone;
666 attackid=-1;
667 reset_swordcharge();
668 drownclk=64;
669 z=fakez=fall=fakefall=0;
670 break;
671
672
673 default:
674 {
675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
676 11 else {action=drowning; FFCore.setHeroAction(drowning);}
677 11 attackclk=0;
678 11 attack=wNone;
679 11 attackid=-1;
680 11 reset_swordcharge();
681 11 drownclk=64;
682 11 z=fakez=fall=fakefall=0;
683 11 break;
684 }
685 }
686
687 11 }
688
689 633 void HeroClass::finishedmsg()
690 {
691 //these are to cancel out any keys that Hero may
692 //be pressing so he doesn't attack at the end of
693 //a message if he was scrolling through it quickly.
694 633 rAbtn();
695 633 rBbtn();
696 633 unfreeze();
697
698
3/4
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 617 times.
1250 if(action == landhold1 ||
699
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 action == landhold2 ||
700
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 action == waterhold1 ||
701
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 action == waterhold2 ||
702
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 action == sidewaterhold1 ||
703 617 action == sidewaterhold2)
704 {
705 16 holdclk = 1;
706 16 }
707 633 }
708 31 void HeroClass::setEaten(int32_t i)
709 {
710 31 inlikelike=i;
711 31 }
712 28 int32_t HeroClass::getEaten()
713 {
714 28 return inlikelike;
715 }
716 12520715 zfix HeroClass::getX()
717 {
718 12520715 return x;
719 }
720 11956240 zfix HeroClass::getY()
721 {
722 11956240 return y;
723 }
724 33520399 zfix HeroClass::getZ()
725 {
726 33520399 return z;
727 }
728 22047079 zfix HeroClass::getFakeZ()
729 {
730 22047079 return fakez;
731 }
732 382611 zfix HeroClass::getFall()
733 {
734 382611 return fall;
735 }
736 zfix HeroClass::getFakeFall()
737 {
738 return fakefall;
739 }
740 zfix HeroClass::getXOfs()
741 {
742 return xofs;
743 }
744 zfix HeroClass::getYOfs()
745 {
746 return yofs;
747 }
748 void HeroClass::setXOfs(int32_t newxofs)
749 {
750 xofs=newxofs;
751 }
752 void HeroClass::setYOfs(int32_t newyofs)
753 {
754 yofs=newyofs;
755 }
756 int32_t HeroClass::getHXOfs()
757 {
758 return hxofs;
759 }
760 int32_t HeroClass::getHYOfs()
761 {
762 return hyofs;
763 }
764 int32_t HeroClass::getHXSz()
765 {
766 return hxsz;
767 }
768 int32_t HeroClass::getHYSz()
769 {
770 return hysz;
771 }
772 24128 zfix HeroClass::getClimbCoverX()
773 {
774 24128 return climb_cover_x;
775 }
776 24128 zfix HeroClass::getClimbCoverY()
777 {
778 24128 return climb_cover_y;
779 }
780 int32_t HeroClass::getLadderX()
781 {
782 return ladderx;
783 }
784 int32_t HeroClass::getLadderY()
785 {
786 return laddery;
787 }
788
789 436513 void HeroClass::setX(int32_t new_x)
790 {
791 436513 zfix dx=new_x-x;
792 436513 justmoved = 2;
793
1/2
✓ Branch 0 taken 436513 times.
✗ Branch 1 not taken.
436513 if(Lwpns.idFirst(wHookshot)>-1)
794 {
795 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
796 hs_startx+=(int32_t)dx;
797 }
798
799
1/2
✓ Branch 0 taken 436513 times.
✗ Branch 1 not taken.
436513 if(Lwpns.idFirst(wHSHandle)>-1)
800 {
801 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
802 }
803
804
1/2
✓ Branch 0 taken 436513 times.
✗ Branch 1 not taken.
436513 if(chainlinks.Count()>0)
805 {
806 for(int32_t j=0; j<chainlinks.Count(); j++)
807 {
808 chainlinks.spr(j)->x+=dx;
809 }
810 }
811
812 436513 x=new_x;
813
814 // A kludge
815
4/4
✓ Branch 0 taken 2223 times.
✓ Branch 1 taken 434290 times.
✓ Branch 2 taken 1553 times.
✓ Branch 3 taken 670 times.
436513 if(!diagonalMovement && dir<=down)
816 670 is_on_conveyor=true;
817 436513 }
818
819 452295 void HeroClass::setY(int32_t new_y)
820 {
821 452295 zfix dy=new_y-y;
822 452295 justmoved = 2;
823
1/2
✓ Branch 0 taken 452295 times.
✗ Branch 1 not taken.
452295 if(Lwpns.idFirst(wHookshot)>-1)
824 {
825 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
826 hs_starty+=(int32_t)dy;
827 }
828
829
1/2
✓ Branch 0 taken 452295 times.
✗ Branch 1 not taken.
452295 if(Lwpns.idFirst(wHSHandle)>-1)
830 {
831 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
832 }
833
834
1/2
✓ Branch 0 taken 452295 times.
✗ Branch 1 not taken.
452295 if(chainlinks.Count()>0)
835 {
836 for(int32_t j=0; j<chainlinks.Count(); j++)
837 {
838 chainlinks.spr(j)->y+=dy;
839 }
840 }
841
842 452295 y=new_y;
843
844 // A kludge
845
4/4
✓ Branch 0 taken 2223 times.
✓ Branch 1 taken 450072 times.
✓ Branch 2 taken 670 times.
✓ Branch 3 taken 1553 times.
452295 if(!diagonalMovement && dir>=left)
846 1553 is_on_conveyor=true;
847 452295 }
848
849 2 void HeroClass::setZ(int32_t new_z)
850 {
851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(isSideViewHero())
852 return;
853
854
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(z==0 && new_z > 0)
855 {
856
1/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 switch(action)
857 {
858 case swimming:
859 {
860 diveclk=0;
861 action=walking; FFCore.setHeroAction(walking);
862 break;
863 }
864
865 case waterhold1:
866 {
867 action=landhold1; FFCore.setHeroAction(landhold1);
868 break;
869 }
870
871 case waterhold2:
872 {
873 action=landhold2; FFCore.setHeroAction(landhold2);
874 break;
875 }
876
877 default:
878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(charging) //!DIMITODO: Let Hero jump while charging sword
879 {
880 reset_swordcharge();
881 attackclk=0;
882 }
883
884 2 break;
885 }
886 2 }
887
888
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 z=(new_z>0 ? new_z : 0);
889 2 }
890
891 void HeroClass::setFakeZ(int32_t new_z)
892 {
893 if(isSideViewHero())
894 return;
895
896 if(fakez==0 && new_z > 0)
897 {
898 switch(action)
899 {
900 case swimming:
901 {
902 diveclk=0;
903 action=walking; FFCore.setHeroAction(walking);
904 break;
905 }
906
907 case waterhold1:
908 {
909 action=landhold1; FFCore.setHeroAction(landhold1);
910 break;
911 }
912
913 case waterhold2:
914 {
915 action=landhold2; FFCore.setHeroAction(landhold2);
916 break;
917 }
918
919 default:
920 if(charging) //!DIMITODO: Let Hero jump while charging sword
921 {
922 reset_swordcharge();
923 attackclk=0;
924 }
925
926 break;
927 }
928 }
929
930 fakez=(new_z>0 ? new_z : 0);
931 }
932
933 1211 void HeroClass::setXfix(zfix new_x)
934 {
935 //Z_scripterrlog("setxdbl: %f\n",new_x);
936 1211 zfix dx=new_x-x;
937 1211 justmoved = 2;
938
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHookshot)>-1)
939 {
940 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
941 hs_startx+=(int32_t)dx;
942 }
943
944
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(Lwpns.idFirst(wHSHandle)>-1)
945 {
946 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
947 }
948
949
1/2
✓ Branch 0 taken 1211 times.
✗ Branch 1 not taken.
1211 if(chainlinks.Count()>0)
950 {
951 for(int32_t j=0; j<chainlinks.Count(); j++)
952 {
953 chainlinks.spr(j)->x+=dx;
954 }
955 }
956
957 1211 x=new_x;
958
959 // A kludge
960
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1211 if(!diagonalMovement && dir<=down)
961 is_on_conveyor=true;
962 1211 }
963
964 1081 void HeroClass::setYfix(zfix new_y)
965 {
966 1081 zfix dy=new_y-y;
967 1081 justmoved = 2;
968
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHookshot)>-1)
969 {
970 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
971 hs_starty+=(int32_t)dy;
972 }
973
974
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(Lwpns.idFirst(wHSHandle)>-1)
975 {
976 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
977 }
978
979
1/2
✓ Branch 0 taken 1081 times.
✗ Branch 1 not taken.
1081 if(chainlinks.Count()>0)
980 {
981 for(int32_t j=0; j<chainlinks.Count(); j++)
982 {
983 chainlinks.spr(j)->y+=dy;
984 }
985 }
986
987 1081 y=new_y;
988
989 // A kludge
990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1081 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1081 if(!diagonalMovement && dir>=left)
991 is_on_conveyor=true;
992 1081 }
993
994 2767 void HeroClass::setZfix(zfix new_z)
995 {
996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2767 times.
2767 if(isSideViewHero())
997 return;
998
999
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 2754 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 7 times.
2767 if(z==0 && new_z > 0)
1000 {
1001
1/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 switch(action)
1002 {
1003 case swimming:
1004 {
1005 diveclk=0;
1006 action=walking; FFCore.setHeroAction(walking);
1007 break;
1008 }
1009
1010 case waterhold1:
1011 {
1012 action=landhold1; FFCore.setHeroAction(landhold1);
1013 break;
1014 }
1015
1016 case waterhold2:
1017 {
1018 action=landhold2; FFCore.setHeroAction(landhold2);
1019 break;
1020 }
1021
1022 default:
1023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(charging) //!DIMITODO: Let Hero jump while charging sword
1024 {
1025 reset_swordcharge();
1026 attackclk=0;
1027 }
1028
1029 7 break;
1030 }
1031 7 }
1032
1033
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 6 times.
2767 z=(new_z>0 ? new_z : zfix(0));
1034 2767 }
1035
1036 void HeroClass::setFakeZfix(zfix new_z)
1037 {
1038 if(isSideViewHero())
1039 return;
1040
1041 if(fakez==0 && new_z > 0)
1042 {
1043 switch(action)
1044 {
1045 case swimming:
1046 {
1047 diveclk=0;
1048 action=walking; FFCore.setHeroAction(walking);
1049 break;
1050 }
1051
1052 case waterhold1:
1053 {
1054 action=landhold1; FFCore.setHeroAction(landhold1);
1055 break;
1056 }
1057
1058 case waterhold2:
1059 {
1060 action=landhold2; FFCore.setHeroAction(landhold2);
1061 break;
1062 }
1063
1064 default:
1065 if(charging) //!DIMITODO: Let Hero jump while charging sword
1066 {
1067 reset_swordcharge();
1068 attackclk=0;
1069 }
1070
1071 break;
1072 }
1073 }
1074
1075 fakez=(new_z>0 ? new_z : zfix(0));
1076 }
1077
1078 64440 void HeroClass::setFall(zfix new_fall)
1079 {
1080 64440 fall=new_fall;
1081 64440 justmoved = 2;
1082 64440 jumping=-1;
1083 64440 }
1084 void HeroClass::setFakeFall(zfix new_fall)
1085 {
1086 fakefall=new_fall;
1087 jumping=-1;
1088 }
1089 void HeroClass::setClimbCoverX(int32_t new_x)
1090 {
1091 climb_cover_x=new_x;
1092 }
1093 void HeroClass::setClimbCoverY(int32_t new_y)
1094 {
1095 climb_cover_y=new_y;
1096 }
1097 40633 int32_t HeroClass::getLStep()
1098 {
1099 40633 return lstep;
1100 }
1101 3465 int32_t HeroClass::getCharging()
1102 {
1103 3465 return charging;
1104 }
1105 53019 bool HeroClass::isCharged()
1106 {
1107 53019 return spins>0;
1108 }
1109 int32_t HeroClass::getAttackClk()
1110 {
1111 return attackclk;
1112 }
1113 void HeroClass::setAttackClk(int32_t new_clk)
1114 {
1115 attackclk=new_clk;
1116 }
1117 void HeroClass::setCharging(int32_t new_charging)
1118 {
1119 charging=new_charging;
1120 }
1121 2286728603 int32_t HeroClass::getSwordClk()
1122 {
1123 2286728603 return swordclk;
1124 }
1125 2260389920 int32_t HeroClass::getItemClk()
1126 {
1127 2260389920 return itemclk;
1128 }
1129 6 void HeroClass::setSwordClk(int32_t newclk)
1130 {
1131 6 swordclk=newclk;
1132 6 verifyAWpn();
1133 6 }
1134 6 void HeroClass::setItemClk(int32_t newclk)
1135 {
1136 6 itemclk=newclk;
1137 6 }
1138 650942 zfix HeroClass::getModifiedX()
1139 {
1140 650942 zfix tempx=x;
1141
1142
4/4
✓ Branch 0 taken 128134 times.
✓ Branch 1 taken 522808 times.
✓ Branch 2 taken 91914 times.
✓ Branch 3 taken 36220 times.
650942 if(screenscrolling&&(dir==left))
1143 {
1144 36220 tempx=tempx+256;
1145 36220 }
1146
1147 650942 return tempx;
1148 }
1149
1150 650942 zfix HeroClass::getModifiedY()
1151 {
1152 650942 zfix tempy=y;
1153
1154
4/4
✓ Branch 0 taken 128134 times.
✓ Branch 1 taken 522808 times.
✓ Branch 2 taken 34239 times.
✓ Branch 3 taken 93895 times.
650942 if(screenscrolling&&(dir==up))
1155 {
1156 34239 tempy=tempy+176;
1157 34239 }
1158
1159 650942 return tempy;
1160 }
1161
1162 9543 int32_t HeroClass::getDir()
1163 {
1164 9543 return dir;
1165 }
1166 16584 void HeroClass::setDir(int32_t newdir)
1167 {
1168 16584 dir=newdir;
1169 16584 reset_hookshot();
1170 16584 }
1171 int32_t HeroClass::getHitDir()
1172 {
1173 return hitdir;
1174 }
1175 void HeroClass::setHitDir(int32_t newdir)
1176 {
1177 hitdir = newdir;
1178 }
1179 int32_t HeroClass::getClk()
1180 {
1181 return clk;
1182 }
1183 int32_t HeroClass::getPushing()
1184 {
1185 return pushing;
1186 }
1187 7177 void HeroClass::Catch()
1188 {
1189
5/6
✓ Branch 0 taken 7177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5331 times.
✓ Branch 3 taken 1846 times.
✓ Branch 4 taken 2991 times.
✓ Branch 5 taken 2340 times.
7177 if(!inwallm && (action==none || action==walking))
1190 {
1191 4837 SetAttack();
1192 4837 attackclk=0;
1193 4837 attack=wCatching;
1194 4837 }
1195 7177 }
1196
1197 4176445 bool HeroClass::getClock()
1198 {
1199 4176445 return superman;
1200 }
1201 635 void HeroClass::setClock(bool state)
1202 {
1203 635 superman=state;
1204 635 }
1205 33820405 int32_t HeroClass::getAction() // Used by ZScript
1206 {
1207
2/2
✓ Branch 0 taken 7632 times.
✓ Branch 1 taken 33812773 times.
33820405 if(spins > 0)
1208 7632 return isspinning;
1209
2/2
✓ Branch 0 taken 17289 times.
✓ Branch 1 taken 33795484 times.
33812773 else if(charging > 0)
1210 17289 return ischarging;
1211
2/2
✓ Branch 0 taken 33765106 times.
✓ Branch 1 taken 30378 times.
33795484 else if(diveclk > 0)
1212 30378 return isdiving;
1213 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1214
1215 33765106 return action;
1216 33820405 }
1217
1218 19759033 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1219 {
1220
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 19758185 times.
19759033 if(spins > 0)
1221 848 return isspinning;
1222
2/2
✓ Branch 0 taken 1921 times.
✓ Branch 1 taken 19756264 times.
19758185 else if(charging > 0)
1223 1921 return ischarging;
1224
2/2
✓ Branch 0 taken 19737600 times.
✓ Branch 1 taken 18664 times.
19756264 else if(diveclk > 0)
1225 18664 return isdiving;
1226 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1227
1228 19737600 return -1;
1229 19759033 }
1230
1231 388 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1232 {
1233
4/8
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 388 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 388 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 388 times.
776 if(new_action==dying || new_action==won || new_action==scrolling ||
1234
3/6
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 388 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 388 times.
✗ Branch 5 not taken.
388 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1235 388 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1236 return; // Can't use these actions.
1237
1238
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
388 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1239 return;
1240
1241
1/2
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
388 if(new_action==rafting)
1242 {
1243 if(get_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING)) return;
1244 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1245 return;
1246 }
1247
1248
1249
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388 if(magicitem>-1 && itemsbuf[magicitem].family==itype_faroreswind)
1250 {
1251 // Using Farore's Wind
1252 if(magiccastclk<96)
1253 {
1254 // Not cast yet; cancel it
1255 magicitem=-1;
1256 magiccastclk=0;
1257 }
1258 else
1259 // Already activated; don't do anything
1260 return;
1261 }
1262
1263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
388 if(action==inwind) // Remove from whirlwind
1264 {
1265 xofs=0;
1266 whirlwind=0;
1267 lstep=0;
1268 if ( dontdraw < 2 ) { dontdraw=0; }
1269 }
1270
2/4
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 388 times.
388 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1271 {
1272 sprite* wind=0;
1273 bool foundWind=false;
1274 for(int32_t i=0; i<Ewpns.Count(); i++)
1275 {
1276 wind=Ewpns.spr(i);
1277 if(wind->id==ewWind && wind->misc==999)
1278 {
1279 foundWind=true;
1280 break;
1281 }
1282 }
1283
1284 if(foundWind)
1285 {
1286 xofs=0;
1287 if ( dontdraw < 2 ) { dontdraw=false; }
1288 wind->misc=-1;
1289 x=wind->x;
1290 y=wind->y;
1291 }
1292 }
1293
1294 //Unless compat rule is on, reset hopping clocks when writing action!
1295
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388 if(action == hopping && !get_bit(quest_rules,qr_NO_OVERWRITING_HOPPING))
1296 {
1297 hopclk = 0;
1298 hopdir = -1;
1299 }
1300
1301
3/4
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 264 times.
388 if(new_action != attacking && new_action != sideswimattacking)
1302 {
1303 264 attackclk=0;
1304
1305
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if(attack==wHookshot)
1306 reset_hookshot();
1307 264 }
1308
2/4
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 388 times.
388 if(new_action != isspinning && new_action != sideswimisspinning)
1309 {
1310 388 charging = 0;
1311 388 spins = 0;
1312 388 }
1313
1314
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388 if(action == falling && new_action != falling)
1315 {
1316 fallclk = 0; //Stop falling;
1317 }
1318
1319
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
388 if (action == rafting && new_action != rafting)
1320 {
1321 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1322 raftwarpy = y;
1323 }
1324
1325
2/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✓ Branch 5 taken 264 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
388 switch(new_action)
1326 {
1327 case isspinning:
1328 case sideswimisspinning:
1329 if(attack==wSword)
1330 {
1331 attackclk = SWORDCHARGEFRAME+1;
1332 charging = 0;
1333
1334 if(spins==0)
1335 spins = 5;
1336 }
1337 return;
1338
1339 case isdiving:
1340 if(action==swimming && diveclk==0)
1341 {
1342 int32_t flippers_id = current_item_id(itype_flippers);
1343 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1344 }
1345 return;
1346
1347 case drowning:
1348 case sidedrowning:
1349 //I would add a sanity check to see if Hero is in water, but I *KNOW* that quests have used this
1350 // INTENTIONALLY while Hero is on Land, as a blink-out effect. :( -Z
1351 if(!drownclk)
1352 Drown();
1353
1354 break;
1355
1356 case lavadrowning:
1357 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1358 if(!drownclk)
1359 Drown(1);
1360
1361 break;
1362
1363 case falling:
1364 if(!fallclk)
1365 {
1366 //If there is a pit under Hero, use it's combo.
1367 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1368 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1369 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1370 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1371 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1372 //Else, use a null value; triggers default pit values
1373 else fallCombo = 0;
1374 fallclk = PITFALL_FALL_FRAMES;
1375 }
1376 break;
1377
1378 case gothit:
1379 case swimhit:
1380 case sideswimhit:
1381 if(!hclk)
1382 hclk=48;
1383
1384 break;
1385
1386 case landhold1:
1387 case landhold2:
1388 case waterhold1:
1389 case waterhold2:
1390 case sidewaterhold1:
1391 case sidewaterhold2:
1392 if(!holdclk)
1393 holdclk=130;
1394
1395 attack=none;
1396 break;
1397
1398 case attacking:
1399 case sideswimattacking:
1400 124 attack=none;
1401 124 break;
1402
1403 default:
1404 264 break;
1405 }
1406
1407 388 action=new_action; FFCore.setHeroAction(new_action);
1408 388 }
1409
1410 void HeroClass::setHeldItem(int32_t newitem)
1411 {
1412 holditem=newitem;
1413 }
1414 17 int32_t HeroClass::getHeldItem()
1415 {
1416 17 return holditem;
1417 }
1418 4954848 bool HeroClass::isDiving()
1419 {
1420 4954848 int32_t flippers_id = current_item_id(itype_flippers);
1421
2/2
✓ Branch 0 taken 3603223 times.
✓ Branch 1 taken 1351625 times.
4954848 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1422 }
1423 11002709 bool HeroClass::isSwimming()
1424 {
1425
4/6
✓ Branch 0 taken 10877091 times.
✓ Branch 1 taken 125618 times.
✓ Branch 2 taken 10877091 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10877091 times.
✗ Branch 5 not taken.
21879800 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1426
4/4
✓ Branch 0 taken 10875661 times.
✓ Branch 1 taken 1430 times.
✓ Branch 2 taken 390 times.
✓ Branch 3 taken 10875271 times.
10877091 (action==waterhold1)||(action==waterhold2)||
1427 10875271 (hopclk==0xFF));
1428 }
1429
1430 621 void HeroClass::setDontDraw(byte new_dontdraw)
1431 {
1432 621 dontdraw=new_dontdraw;
1433 621 }
1434
1435 380933 byte HeroClass::getDontDraw()
1436 {
1437 380933 return dontdraw;
1438 }
1439
1440 void HeroClass::setHClk(int32_t newhclk)
1441 {
1442 hclk=newhclk;
1443 }
1444
1445 87306 int32_t HeroClass::getHClk()
1446 {
1447 87306 return hclk;
1448 }
1449
1450 2862537 int32_t HeroClass::getSpecialCave()
1451 {
1452 2862537 return specialcave; // used only by maps.cpp
1453 }
1454
1455 248 void HeroClass::init()
1456 {
1457 248 usecounts.clear();
1458 248 scale = 0;
1459 248 rotation = 0;
1460 248 do_animation = 1;
1461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if(lift_wpn)
1462 {
1463 delete lift_wpn;
1464 lift_wpn = nullptr;
1465 }
1466 248 liftclk = 0;
1467 248 tliftclk = 0;
1468 248 liftheight = 0;
1469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1470 248 hookshot_used=false;
1471 248 justmoved = 0;
1472 248 hookshot_frozen=false;
1473 248 onpassivedmg=false;
1474 248 dir = up;
1475 248 damageovertimeclk = 0;
1476 248 newconveyorclk = 0;
1477 248 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1478
2/2
✓ Branch 0 taken 1736 times.
✓ Branch 1 taken 248 times.
1984 for(auto q = 0; q < 7; ++q)
1479 1736 hooked_undercombos[q] = -1;
1480 248 shiftdir = -1;
1481 248 sideswimdir = right;
1482 248 holddir = -1;
1483 248 landswim = 0;
1484 248 sdir = up;
1485 248 ilswim=true;
1486 248 walkable=false;
1487 248 moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL | FLAG_CAN_WATERDROWN;
1488 248 warp_sound = 0;
1489 248 subscr_speed = zinit.subscrSpeed;
1490 248 steprate = zinit.heroStep;
1491 248 is_warping = false;
1492 248 can_mirror_portal = true;
1493 248 coyotetime = 0;
1494
1495 248 hammer_swim_up_offset = hammeroffsets[0];
1496 248 hammer_swim_down_offset = hammeroffsets[1];
1497 248 hammer_swim_left_offset = hammeroffsets[2];
1498 248 hammer_swim_right_offset = hammeroffsets[3];
1499
1500 248 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1501
1502
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 169 times.
248 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
1503 {
1504 79 x=tmpscr->warpreturnx[0];
1505 79 y=tmpscr->warpreturny[0];
1506 79 }
1507 else
1508 {
1509 169 x=tmpscr->warparrivalx;
1510 169 y=tmpscr->warparrivaly;
1511 }
1512
1513 248 z=fakez=fall=fakefall=0;
1514 248 hzsz = 12; // So that flying peahats can still hit him.
1515
1516
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 189 times.
248 if(x==0) dir=right;
1517
1518
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 247 times.
248 if(x==240) dir=left;
1519
1520
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 189 times.
248 if(y==0) dir=down;
1521
1522
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 198 times.
248 if(y==160) dir=up;
1523
1524 248 lstep=0;
1525 248 skipstep=0;
1526 248 autostep=false;
1527 248 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1528 248 attack=wNone;
1529 248 attackid=-1;
1530 248 action=none; FFCore.setHeroAction(none); tempaction=none;
1531 248 xofs=0;
1532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1533 248 cs=6;
1534 248 pushing=fairyclk=0;
1535 248 id=0;
1536 248 inlikelike=0;
1537 248 superman=inwallm=false;
1538 248 scriptcoldet=1;
1539 248 blowcnt=whirlwind=specialcave=0;
1540 248 hopclk=diveclk=fallclk=0;
1541 248 fallCombo = 0;
1542 248 pit_pulldir = -1;
1543 248 hopdir=-1;
1544 248 conveyor_flags=0;
1545 248 drunkclk=0;
1546 248 lstunclock = 0;
1547 248 is_conveyor_stunned=0;
1548 248 drawstyle=3;
1549 248 ffwarp = false;
1550 248 stepoutindex=stepoutwr=stepoutdmap=stepoutscr=0;
1551 248 stepnext=stepsecret=-1;
1552 248 ffpit = false;
1553 248 respawn_x=x;
1554 248 respawn_y=y;
1555 248 respawn_dmap=currdmap;
1556 248 respawn_scr=currscr;
1557 248 falling_oldy = y;
1558 248 magiccastclk=0;
1559 248 magicitem = nayruitem = -1;
1560 248 last_lens_id = 0; //Should be -1 (-Z)
1561 248 last_savepoint_id = 0;
1562 248 misc_internal_hero_flags = 0;
1563 248 last_cane_of_byrna_item_id = -1;
1564 248 on_sideview_ladder = false;
1565 248 switchblock_z = 0;
1566 248 switchblock_offset = false;
1567 248 extra_jump_count = 0;
1568 248 hoverflags = 0;
1569 248 lbunnyclock = 0;
1570
1571
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 248 times.
8184 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1572
1573 248 setBigHitbox(get_bit(quest_rules, qr_LTTPCOLLISION));
1574 248 diagonalMovement=(get_bit(quest_rules,qr_LTTPWALK));
1575
1576 248 shield_active = false;
1577 248 shield_forcedir = -1;
1578 248 active_shield_id = -1;
1579
1580 //2.6
1581 248 preventsubscreenfalling = false; //-Z
1582 248 walkspeed = 0; //not used, yet. -Z
1583
2/2
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 248 times.
4216 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1584
2/2
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 248 times.
4216 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1585
2/2
✓ Branch 0 taken 36208 times.
✓ Branch 1 taken 248 times.
36456 for ( int32_t q = 0; q < wMax; q++ )
1586 {
1587 36208 defence[q] = hero_defence[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1588 //zprint2("defence[%d] is: %d\n", q, defence[q]);
1589 36208 }
1590 //Run script!
1591
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 17 times.
248 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1592 {
1593 14 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT, SCRIPT_PLAYER_INIT);
1594 14 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_INIT);
1595 14 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1596 14 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1597 //are properly set by the engine.
1598 14 }
1599 248 FFCore.nostepforward = 0;
1600
1601
3/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 219 times.
248 if (!replay_is_active() || replay_get_version() >= 12)
1602 29 z3step = 2;
1603 248 }
1604
1605 5877592 void HeroClass::draw_under(BITMAP* dest)
1606 {
1607 5877592 int32_t c_raft=current_item_id(itype_raft);
1608 5877592 int32_t c_ladder=current_item_id(itype_ladder);
1609
1610
3/4
✓ Branch 0 taken 76431 times.
✓ Branch 1 taken 5801161 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76431 times.
5877592 if(action==rafting && c_raft >-1)
1611 {
1612
4/4
✓ Branch 0 taken 56381 times.
✓ Branch 1 taken 20050 times.
✓ Branch 2 taken 39548 times.
✓ Branch 3 taken 36883 times.
76431 if(((dir==left) || (dir==right)) && (get_bit(quest_rules,qr_RLFIX)))
1613 {
1614 73766 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1615 36883 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1616 36883 }
1617 else
1618 {
1619 79096 overtile16(dest, itemsbuf[c_raft].tile, x, y+playing_field_offset+4,
1620 39548 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1621 }
1622 76431 }
1623
1624
3/4
✓ Branch 0 taken 92037 times.
✓ Branch 1 taken 5785555 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 92037 times.
5877592 if(ladderx+laddery && c_ladder >-1)
1625 {
1626
4/4
✓ Branch 0 taken 41373 times.
✓ Branch 1 taken 50664 times.
✓ Branch 2 taken 23006 times.
✓ Branch 3 taken 18367 times.
92037 if((ladderdir>=left) && (get_bit(quest_rules,qr_RLFIX)))
1627 {
1628 46012 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1629 23006 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[iRaft].misc_flags>>2)&3)^3);
1630 23006 }
1631 else
1632 {
1633 138062 overtile16(dest, itemsbuf[c_ladder].tile, ladderx, laddery+playing_field_offset,
1634 69031 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1635 }
1636 92037 }
1637 5877592 }
1638
1639 3357 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1640 {
1641 3357 int32_t tempy=yofs;
1642 3357 yofs+=8;
1643 3357 shadowtile = wpnsbuf[spr_shadow].tile;
1644 3357 sprite::drawshadow(dest,translucent);
1645 3357 yofs=tempy;
1646 3357 }
1647
1648 // The Stone of Agony reacts to these flags.
1649 488068 bool HeroClass::agonyflag(int32_t flag)
1650 {
1651
2/2
✓ Branch 0 taken 488036 times.
✓ Branch 1 taken 32 times.
488068 switch(flag)
1652 {
1653 case mfWHISTLE:
1654 case mfBCANDLE:
1655 case mfARROW:
1656 case mfBOMB:
1657 case mfSBOMB:
1658 case mfBRANG:
1659 case mfMBRANG:
1660 case mfFBRANG:
1661 case mfSARROW:
1662 case mfGARROW:
1663 case mfRCANDLE:
1664 case mfWANDFIRE:
1665 case mfDINSFIRE:
1666 case mfWANDMAGIC:
1667 case mfREFMAGIC:
1668 case mfREFFIREBALL:
1669 case mfSWORD:
1670 case mfWSWORD:
1671 case mfMSWORD:
1672 case mfXSWORD:
1673 case mfSWORDBEAM:
1674 case mfWSWORDBEAM:
1675 case mfMSWORDBEAM:
1676 case mfXSWORDBEAM:
1677 case mfHOOKSHOT:
1678 case mfWAND:
1679 case mfHAMMER:
1680 case mfSTRIKE:
1681 32 return true;
1682 }
1683
1684 488036 return false;
1685 488068 }
1686
1687
1688 // Find the attack power of the current melee weapon.
1689 // The Whimsical Ring is applied on a target-by-target basis.
1690 383312 int32_t HeroClass::weaponattackpower(int32_t itid)
1691 {
1692
1/2
✓ Branch 0 taken 383312 times.
✗ Branch 1 not taken.
383312 if(itid < 0)
1693 {
1694 itid = current_item_id(attack==wCByrna ? itype_cbyrna
1695 : attack==wWand ? itype_wand
1696 : attack==wHammer ? itype_hammer
1697 : itype_sword);
1698 }
1699
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 383292 times.
383312 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
1700
1701 // Multiply it by the power of the spin attack/quake hammer, if applicable.
1702
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 382738 times.
383312 if(spins > 0)
1703 {
1704 574 int scr = currentscroll;
1705
1/2
✓ Branch 0 taken 574 times.
✗ Branch 1 not taken.
574 if(scr < 0)
1706 {
1707 scr = current_item_id(attack==wHammer ? (spins>1?itype_quakescroll2:itype_quakescroll)
1708 : (spins>5 || current_item_id(itype_spinscroll) < 0)
1709 ? itype_spinscroll2 : itype_spinscroll);
1710 }
1711 574 power *= itemsbuf[scr].power;
1712 574 }
1713 382738 else currentscroll = -1;
1714 383312 return power;
1715 }
1716
1717 #define NET_CLK_TOTAL 24
1718 #define NET_DIR_INC (NET_CLK_TOTAL/3)
1719 // Must only be called once per frame!
1720 void HeroClass::positionNet(weapon *w, int32_t itemid)
1721 {
1722 itemid = vbound(itemid, 0, MAXITEMS-1);
1723 int32_t t = w->o_tile,
1724 wx = 1, wy = 1;
1725
1726 //Invert positioning clock if right-handed animation
1727 int32_t clock = (itemsbuf[itemid].flags&ITEM_FLAG2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
1728 if(clock >= NET_CLK_TOTAL)
1729 w->dead = 0;
1730 int32_t tiledir = dir;
1731 switch(dir)
1732 {
1733 case up:
1734 {
1735 if(clock < NET_DIR_INC) tiledir = l_up;
1736 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
1737 break;
1738 }
1739 case down:
1740 {
1741 if(clock < NET_DIR_INC) tiledir = r_down;
1742 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
1743 break;
1744 }
1745 case left:
1746 {
1747 if(clock < NET_DIR_INC) tiledir = l_down;
1748 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
1749 break;
1750 }
1751 case right:
1752 {
1753 if(clock < NET_DIR_INC) tiledir = r_up;
1754 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
1755 break;
1756 }
1757 }
1758 int32_t offs = 0;
1759 if(tiledir > right)
1760 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
1761 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
1762 //One of 8 positions
1763 switch(tiledir)
1764 {
1765 case up:
1766 {
1767 wx = 6*offs;
1768 wy = -14;
1769 break;
1770 }
1771 case r_up:
1772 {
1773 wx = (offs ? 10 : 14);
1774 wy = (offs ? -12 : -10);
1775 break;
1776 }
1777 case right:
1778 {
1779 wx = 14;
1780 wy = 6*offs;
1781 break;
1782 }
1783 case r_down:
1784 {
1785 wx = (offs ? 14 : 10);
1786 wy = (offs ? 10 : 12);
1787 break;
1788 }
1789 case down:
1790 {
1791 wx = -6*offs;
1792 wy = 14;
1793 break;
1794 }
1795 case l_down:
1796 {
1797 wx = (offs ? -10 : -14);
1798 wy = (offs ? 12 : 10);
1799 break;
1800 }
1801 case left:
1802 {
1803 wx = -14;
1804 wy = -6*offs;
1805 break;
1806 }
1807 case l_up:
1808 {
1809 wx = (offs ? -14 : -10);
1810 wy = (offs ? -10 : -12);
1811 break;
1812 }
1813 }
1814
1815 w->x = x+wx;
1816 w->y = y+wy-(54-(yofs))-fakez;
1817 w->z = (z+zofs);
1818 w->fakez = fakez;
1819 w->tile = t+tiledir;
1820 w->power = 0;
1821 w->dir = dir;
1822 w->doAutoRotate(true);
1823 }
1824 351265 void HeroClass::positionSword(weapon *w, int32_t itemid)
1825 {
1826 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
1827 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
1828 351265 itemid=vbound(itemid, 0, MAXITEMS-1);
1829 // Place a sword weapon at the right spot.
1830 351265 int32_t wy=1;
1831 351265 int32_t wx=1;
1832 351265 int32_t f=0,t,cs2;
1833
1834 351265 t = w->o_tile;
1835 351265 cs2 = w->o_cset;
1836 351265 slashxofs=0;
1837 351265 slashyofs=0;
1838
1839
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 78603 times.
✓ Branch 2 taken 76353 times.
✓ Branch 3 taken 97273 times.
✓ Branch 4 taken 99036 times.
351265 switch(dir)
1840 {
1841 case up:
1842 78603 wx=-1;
1843 78603 wy=-12;
1844
1845
7/8
✓ Branch 0 taken 6693 times.
✓ Branch 1 taken 71910 times.
✓ Branch 2 taken 5640 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 5230 times.
✓ Branch 5 taken 410 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5230 times.
78603 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1846 {
1847
2/2
✓ Branch 0 taken 3418 times.
✓ Branch 1 taken 1812 times.
5230 if(attackclk>10) //extended stab
1848 {
1849 1812 slashyofs-=3;
1850 1812 wy-=2;
1851 1812 }
1852
1853
2/2
✓ Branch 0 taken 4778 times.
✓ Branch 1 taken 452 times.
5230 if(attackclk>=14) //retracting stab
1854 {
1855 452 slashyofs+=3;
1856 452 wy+=2;
1857 452 }
1858 5230 }
1859 else
1860 {
1861
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 73087 times.
73373 if(attackclk==SWORDCHARGEFRAME)
1862 {
1863 286 wy+=4;
1864 286 }
1865
2/2
✓ Branch 0 taken 7086 times.
✓ Branch 1 taken 66001 times.
73087 else if(attackclk==13)
1866 {
1867 7086 wy+=4;
1868 7086 }
1869
2/2
✓ Branch 0 taken 59012 times.
✓ Branch 1 taken 6989 times.
66001 else if(attackclk==14)
1870 {
1871 6989 wy+=8;
1872 6989 }
1873 }
1874
1875 78603 break;
1876
1877 case down:
1878 76353 f=get_bit(quest_rules,qr_SWORDWANDFLIPFIX)?3:2;
1879 76353 wy=11;
1880
1881
7/8
✓ Branch 0 taken 9260 times.
✓ Branch 1 taken 67093 times.
✓ Branch 2 taken 8503 times.
✓ Branch 3 taken 757 times.
✓ Branch 4 taken 8143 times.
✓ Branch 5 taken 360 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 8143 times.
76353 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1882 {
1883
2/2
✓ Branch 0 taken 5288 times.
✓ Branch 1 taken 2855 times.
8143 if(attackclk>10) //extended stab
1884 {
1885 2855 slashyofs+=3;
1886 2855 wy+=2;
1887 2855 }
1888
1889
2/2
✓ Branch 0 taken 7441 times.
✓ Branch 1 taken 702 times.
8143 if(attackclk>=14) //retracting stab
1890 {
1891 702 slashyofs-=3;
1892 702 wy-=2;
1893 702 }
1894 8143 }
1895 else
1896 {
1897
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 67610 times.
68210 if(attackclk==SWORDCHARGEFRAME)
1898 {
1899 600 wy-=2;
1900 600 }
1901
2/2
✓ Branch 0 taken 6617 times.
✓ Branch 1 taken 60993 times.
67610 else if(attackclk==13)
1902 {
1903 6617 wy-=4;
1904 6617 }
1905
2/2
✓ Branch 0 taken 54403 times.
✓ Branch 1 taken 6590 times.
60993 else if(attackclk==14)
1906 {
1907 6590 wy-=8;
1908 6590 }
1909 }
1910
1911 76353 break;
1912
1913 case left:
1914 97273 f=1;
1915 97273 wx=-11;
1916 97273 ++t;
1917
1918
7/8
✓ Branch 0 taken 12751 times.
✓ Branch 1 taken 84522 times.
✓ Branch 2 taken 10433 times.
✓ Branch 3 taken 2318 times.
✓ Branch 4 taken 9581 times.
✓ Branch 5 taken 852 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9581 times.
97273 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1919 {
1920
2/2
✓ Branch 0 taken 6140 times.
✓ Branch 1 taken 3441 times.
9581 if(attackclk>10) //extended stab
1921 {
1922 3441 slashxofs-=4;
1923 3441 wx-=7;
1924 3441 }
1925
1926
2/2
✓ Branch 0 taken 8726 times.
✓ Branch 1 taken 855 times.
9581 if(attackclk>=14) //retracting stab
1927 {
1928 855 slashxofs+=3;
1929 855 wx+=7;
1930 855 }
1931 9581 }
1932 else
1933 {
1934
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 87489 times.
87692 if(attackclk==SWORDCHARGEFRAME)
1935 {
1936 203 wx+=2;
1937 203 }
1938
2/2
✓ Branch 0 taken 8617 times.
✓ Branch 1 taken 78872 times.
87489 else if(attackclk==13)
1939 {
1940 8617 wx+=4;
1941 8617 }
1942
2/2
✓ Branch 0 taken 70289 times.
✓ Branch 1 taken 8583 times.
78872 else if(attackclk==14)
1943 {
1944 8583 wx+=8;
1945 8583 }
1946 }
1947
1948 97273 break;
1949
1950 case right:
1951 99036 wx=11;
1952 99036 ++t;
1953
1954
7/8
✓ Branch 0 taken 12948 times.
✓ Branch 1 taken 86088 times.
✓ Branch 2 taken 11071 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 9237 times.
✓ Branch 5 taken 1834 times.
✓ Branch 6 taken 9237 times.
✗ Branch 7 not taken.
99036 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & ITEM_FLAG4 && charging==0)
1955 {
1956
2/2
✓ Branch 0 taken 5924 times.
✓ Branch 1 taken 3313 times.
9237 if(attackclk>10) //extended stab
1957 {
1958 3313 slashxofs+=4;
1959 3313 wx+=7;
1960 3313 }
1961
1962
2/2
✓ Branch 0 taken 8410 times.
✓ Branch 1 taken 827 times.
9237 if(attackclk>=14) //retracting stab
1963 {
1964 827 slashxofs-=3;
1965 827 wx-=7;
1966 827 }
1967 9237 }
1968 else
1969 {
1970
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 89204 times.
89799 if(attackclk==SWORDCHARGEFRAME)
1971 {
1972 595 wx-=2;
1973 595 }
1974
2/2
✓ Branch 0 taken 8756 times.
✓ Branch 1 taken 80448 times.
89204 else if(attackclk==13)
1975 {
1976 8756 wx-=4;
1977 8756 }
1978
2/2
✓ Branch 0 taken 71717 times.
✓ Branch 1 taken 8731 times.
80448 else if(attackclk==14)
1979 {
1980 8731 wx-=8;
1981 8731 }
1982 }
1983
1984 99036 break;
1985 }
1986
1987
6/6
✓ Branch 0 taken 41652 times.
✓ Branch 1 taken 309613 times.
✓ Branch 2 taken 32211 times.
✓ Branch 3 taken 9441 times.
✓ Branch 4 taken 11429 times.
✓ Branch 5 taken 20782 times.
351265 if(game->get_canslash() && itemsbuf[itemid].flags & ITEM_FLAG4 && attackclk<11)
1988 {
1989 20782 int32_t wpn2=itemsbuf[itemid].wpn2;
1990 20782 wpn2=vbound(wpn2, 0, MAXWPNS);
1991
1992 //slashing tiles
1993
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3418 times.
✓ Branch 2 taken 5294 times.
✓ Branch 3 taken 6140 times.
✓ Branch 4 taken 5930 times.
20782 switch(dir)
1994 {
1995 case up:
1996 3418 wx=15;
1997 3418 wy=-3;
1998 3418 ++t;
1999 3418 f=0; //starts pointing right
2000
2001
2/2
✓ Branch 0 taken 1533 times.
✓ Branch 1 taken 1885 times.
3418 if(attackclk>=7)
2002 {
2003 1885 wy-=9;
2004 1885 wx-=3;
2005 1885 t = wpnsbuf[wpn2].tile;
2006 1885 cs2 = wpnsbuf[wpn2].csets&15;
2007 1885 f=0;
2008 1885 }
2009
2010 3418 break;
2011
2012 case down:
2013 5294 wx=-13;
2014 5294 wy=-1;
2015 5294 ++t;
2016 5294 f=1; //starts pointing left
2017
2018
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 2990 times.
5294 if(attackclk>=7)
2019 {
2020 2990 wy+=15;
2021 2990 wx+=2;
2022 2990 t = wpnsbuf[wpn2].tile;
2023 2990 cs2 = wpnsbuf[wpn2].csets&15;
2024 2990 ++t;
2025 2990 f=0;
2026 2990 }
2027
2028 5294 break;
2029
2030 case left:
2031 6140 wx=3;
2032 6140 wy=-15;
2033 6140 --t;
2034 6140 f=0; //starts pointing up
2035
2036
2/2
✓ Branch 0 taken 2658 times.
✓ Branch 1 taken 3482 times.
6140 if(attackclk>=7)
2037 {
2038 3482 wx-=15;
2039 3482 wy+=3;
2040 3482 slashxofs-=1;
2041 3482 t = wpnsbuf[wpn2].tile;
2042 3482 cs2 = wpnsbuf[wpn2].csets&15;
2043 3482 t+=2;
2044 3482 f=0;
2045 3482 }
2046
2047 6140 break;
2048
2049 case right:
2050 5930 --t;
2051
2052
2/4
✓ Branch 0 taken 5930 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5930 times.
5930 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2053 {
2054 wx=1;
2055 wy=13;
2056 f=2;
2057 }
2058 else
2059 {
2060 5930 wx=3;
2061 5930 wy=-15;
2062 5930 f=0;
2063 }
2064
2065
2/2
✓ Branch 0 taken 2579 times.
✓ Branch 1 taken 3351 times.
5930 if(attackclk>=7)
2066 {
2067 3351 wx+=15;
2068 3351 slashxofs+=1;
2069 3351 t = wpnsbuf[wpn2].tile;
2070 3351 cs2 = wpnsbuf[wpn2].csets&15;
2071
2072
2/4
✓ Branch 0 taken 3351 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3351 times.
3351 if(spins>0 || (itemsbuf[itemid].flags & ITEM_FLAG8))
2073 {
2074 wx-=1;
2075 wy-=2;
2076 }
2077 else
2078 {
2079 3351 t+=3;
2080 3351 f=0;
2081 3351 wy+=3;
2082 }
2083 3351 }
2084
2085 5930 break;
2086 }
2087 20782 }
2088
2089 351265 int32_t itemid2 = current_item_id(itype_chargering);
2090
2091
4/4
✓ Branch 0 taken 21741 times.
✓ Branch 1 taken 329524 times.
✓ Branch 2 taken 350733 times.
✓ Branch 3 taken 532 times.
351265 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2092 {
2093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2094 532 }
2095
2096 /*if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2097 {
2098 wy+=2;
2099 }*/
2100 351265 w->x = x+wx;
2101 351265 w->y = y+wy-(54-(yofs+slashyofs))-fakez;
2102 351265 w->z = (z+zofs);
2103 351265 w->tile = t;
2104 351265 w->flip = f;
2105 351265 w->power = weaponattackpower(itemid);
2106 351265 w->dir = dir;
2107 351265 w->doAutoRotate(true);
2108 351265 }
2109
2110 5903921 void HeroClass::draw(BITMAP* dest)
2111 {
2112 /*{
2113 char buf[36];
2114 //sprintf(buf,"%d %d %d %d %d %d %d",dir, action, attack, attackclk, charging, spins, tapping);
2115 textout_shadowed_ex(framebuf,font, buf, 2,72,WHITE,BLACK,-1);
2116 }*/
2117 int32_t oxofs, oyofs;
2118 5903921 bool shieldModify = false;
2119
2/2
✓ Branch 0 taken 5894336 times.
✓ Branch 1 taken 9585 times.
5903921 bool invisible=(dontdraw>0) || (tmpscr->flags3&fINVISHERO);
2120
2121
2/2
✓ Branch 0 taken 1560 times.
✓ Branch 1 taken 5902361 times.
5903921 if(action==dying)
2122 {
2123
2/2
✓ Branch 0 taken 1196 times.
✓ Branch 1 taken 364 times.
1560 if(!invisible)
2124 {
2125
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2126 364 sprite::draw(dest);
2127 364 }
2128 1560 return;
2129 }
2130
2131 5902361 bool useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2132
2133 5902361 oxofs=xofs;
2134 5902361 oyofs=yofs;
2135
2136
2/2
✓ Branch 0 taken 45134 times.
✓ Branch 1 taken 5857227 times.
5902361 if(!invisible)
2137
6/6
✓ Branch 0 taken 5113543 times.
✓ Branch 1 taken 743684 times.
✓ Branch 2 taken 3314780 times.
✓ Branch 3 taken 1798763 times.
✓ Branch 4 taken 157100 times.
✓ Branch 5 taken 3157680 times.
5857227 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2138
2139 // Stone of Agony
2140 5902361 bool agony=false;
2141 5902361 int32_t agonyid = current_item_id(itype_agony);
2142
2143
2/2
✓ Branch 0 taken 45134 times.
✓ Branch 1 taken 5857227 times.
5902361 if(invisible)
2144 45134 goto attack;
2145
2146
2/2
✓ Branch 0 taken 5613185 times.
✓ Branch 1 taken 244042 times.
5857227 if(agonyid>-1)
2147 {
2148 244042 int32_t power=itemsbuf[agonyid].power;
2149 244042 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2150 244042 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2151 244042 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2152 244042 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2153
2154
2/2
✓ Branch 0 taken 244042 times.
✓ Branch 1 taken 244042 times.
488084 for(int32_t x=left; x<right; x+=16)
2155 {
2156
2/2
✓ Branch 0 taken 244010 times.
✓ Branch 1 taken 244042 times.
488052 for(int32_t y=top; y<bottom; y+=16)
2157 {
2158
4/4
✓ Branch 0 taken 244026 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 244010 times.
244042 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2159 {
2160 32 agony=true;
2161 32 x=right; // Break out of outer loop
2162 32 break;
2163 }
2164 244010 }
2165 244042 }
2166 244042 }
2167
2168 5857227 cs = 6;
2169
1/2
✓ Branch 0 taken 5857227 times.
✗ Branch 1 not taken.
5857227 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2170
2/2
✓ Branch 0 taken 1301062 times.
✓ Branch 1 taken 4556165 times.
10413392 if(!get_bit(quest_rules,qr_HEROFLICKER))
2171 {
2172
3/4
✓ Branch 0 taken 71984 times.
✓ Branch 1 taken 4484181 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71984 times.
4556165 if(superman && getCanFlicker())
2173 {
2174 71984 cs += (((~frame)>>1)&3);
2175 71984 }
2176
4/6
✓ Branch 0 taken 185506 times.
✓ Branch 1 taken 4298675 times.
✓ Branch 2 taken 185506 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 185506 times.
4484181 else if(hclk&&(NayrusLoveShieldClk<=0) && getCanFlicker())
2177 {
2178 185506 cs += ((hclk>>1)&3);
2179 185506 }
2180 4556165 }
2181
2182 attack:
2183
2184
5/6
✓ Branch 0 taken 5264700 times.
✓ Branch 1 taken 637661 times.
✓ Branch 2 taken 5259792 times.
✓ Branch 3 taken 4908 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5259792 times.
5902361 if(attackclk || (action==attacking||action==sideswimattacking))
2185 {
2186 /* Spaghetti code constants!
2187 * - Hero.attack contains a weapon type...
2188 * - which must be converted to an itype...
2189 * - which must be converted to an item ID...
2190 * - which is used to acquire a wpn ID! Aack!
2191 */
2192
8/8
✓ Branch 0 taken 11599 times.
✓ Branch 1 taken 630970 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 630942 times.
✓ Branch 4 taken 16906 times.
✓ Branch 5 taken 614036 times.
✓ Branch 6 taken 2876 times.
✓ Branch 7 taken 611160 times.
642569 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2193
4/4
✓ Branch 0 taken 29427 times.
✓ Branch 1 taken 613142 times.
✓ Branch 2 taken 907 times.
✓ Branch 3 taken 28520 times.
642569 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
2194 642569 itemid=vbound(itemid, 0, MAXITEMS-1);
2195 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2196
7/8
✓ Branch 0 taken 208114 times.
✓ Branch 1 taken 434455 times.
✓ Branch 2 taken 208114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 138735 times.
✓ Branch 5 taken 69379 times.
✓ Branch 6 taken 13522 times.
✓ Branch 7 taken 125213 times.
642569 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2197 {
2198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 447977 times.
447977 if(attack == wBugNet)
2199 {
2200 weapon *w=NULL;
2201 bool found = false;
2202 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2203 {
2204 w = (weapon*)Lwpns.spr(q);
2205 if(w->id == wBugNet)
2206 {
2207 found = true;
2208 break;
2209 }
2210 }
2211 if(!found)
2212 {
2213 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2214
2215 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2216 }
2217 positionNet(w, itemid);
2218 }
2219
8/8
✓ Branch 0 taken 98692 times.
✓ Branch 1 taken 349285 times.
✓ Branch 2 taken 86618 times.
✓ Branch 3 taken 12074 times.
✓ Branch 4 taken 78631 times.
✓ Branch 5 taken 7987 times.
✓ Branch 6 taken 86598 times.
✓ Branch 7 taken 361379 times.
447977 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2220 {
2221 // Create a sword weapon at the right spot.
2222 361379 weapon *w=NULL;
2223 361379 bool found = false;
2224
2225 // Look for pre-existing sword
2226
2/2
✓ Branch 0 taken 35068 times.
✓ Branch 1 taken 422704 times.
457772 for(int32_t i=0; i<Lwpns.Count(); i++)
2227 {
2228 422704 w = (weapon*)Lwpns.spr(i);
2229
2230
2/2
✓ Branch 0 taken 96393 times.
✓ Branch 1 taken 326311 times.
422704 if(w->id == (attack==wSword ? wSword : wWand))
2231 {
2232 326311 found = true;
2233 326311 break;
2234 }
2235 96393 }
2236
2237
2/2
✓ Branch 0 taken 326311 times.
✓ Branch 1 taken 35068 times.
361379 if(!found) // Create one if sword nonexistant
2238 {
2239
5/10
✓ Branch 0 taken 35068 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35068 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35068 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 35068 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 35068 times.
✗ Branch 9 not taken.
35068 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2240 35068 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2241
2242 35068 positionSword(w,itemid);
2243
2244 // Stone of Agony
2245
1/2
✓ Branch 0 taken 35068 times.
✗ Branch 1 not taken.
35068 if(agony)
2246 {
2247 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2248 }
2249 35068 }
2250
2251 // These are set by positionSword(), above or in checkstab()
2252 361379 yofs += slashyofs;
2253 361379 xofs += slashxofs;
2254 361379 slashyofs = slashxofs = 0;
2255 361379 }
2256 447977 }
2257
2258 642569 if(attackclk<7
2259
4/4
✓ Branch 0 taken 338410 times.
✓ Branch 1 taken 304159 times.
✓ Branch 2 taken 267532 times.
✓ Branch 3 taken 70878 times.
642569 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2260
4/6
✓ Branch 0 taken 61122 times.
✓ Branch 1 taken 206410 times.
✓ Branch 2 taken 61122 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 61122 times.
267532 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2261
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 59309 times.
61122 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2262
4/4
✓ Branch 0 taken 122147 times.
✓ Branch 1 taken 8040 times.
✓ Branch 2 taken 115966 times.
✓ Branch 3 taken 6181 times.
132000 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2263
4/4
✓ Branch 0 taken 10423 times.
✓ Branch 1 taken 119764 times.
✓ Branch 2 taken 2294 times.
✓ Branch 3 taken 117470 times.
130187 || (attack==wHammer && attackclk<=30)
2264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117470 times.
119764 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2265 {
2266
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 525077 times.
525099 if(!invisible)
2267 {
2268 525077 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2269
2/4
✓ Branch 0 taken 525077 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 525077 times.
✗ Branch 3 not taken.
525077 if (FIXED_Z3_ANIMATION)
2270 {
2271 if (attackclk >= 2) tile += (extend==2?2:1);
2272 if (attackclk >= 13) tile += (extend==2?2:1);
2273 }
2274
2275
14/18
✓ Branch 0 taken 58722 times.
✓ Branch 1 taken 466355 times.
✓ Branch 2 taken 13042 times.
✓ Branch 3 taken 45680 times.
✓ Branch 4 taken 5786 times.
✓ Branch 5 taken 7256 times.
✓ Branch 6 taken 4967 times.
✓ Branch 7 taken 819 times.
✓ Branch 8 taken 41282 times.
✓ Branch 9 taken 17440 times.
✓ Branch 10 taken 23091 times.
✓ Branch 11 taken 18191 times.
✓ Branch 12 taken 23091 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 23091 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
525077 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&ITEM_FLAG4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2276 {
2277 18191 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2278
2/4
✓ Branch 0 taken 18191 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18191 times.
✗ Branch 3 not taken.
18191 if (FIXED_Z3_ANIMATION)
2279 {
2280 if (attackclk >= 7) tile += (extend==2?2:1);
2281 if (attackclk >= 11) tile += (extend==2?2:1);
2282 if (attackclk >= 14) tile += (extend==2?2:1);
2283 }
2284 18191 }
2285
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 525077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
525077 if (attack==wBugNet && !get_bit(quest_rules, qr_OLD_BUG_NET))
2286 {
2287 if ((dir == right && (itemsbuf[itemid].flags&ITEM_FLAG2)) || (dir != right && !(itemsbuf[itemid].flags&ITEM_FLAG2)))
2288 {
2289 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2290 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2291 }
2292 else
2293 {
2294 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2295 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2296 }
2297 }
2298
2299
4/4
✓ Branch 0 taken 2876 times.
✓ Branch 1 taken 522201 times.
✓ Branch 2 taken 1710 times.
✓ Branch 3 taken 1166 times.
525077 if((attack==wHammer) && (attackclk<13))
2300 {
2301 1166 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2302
2/4
✓ Branch 0 taken 1166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1166 times.
✗ Branch 3 not taken.
1166 if (FIXED_Z3_ANIMATION)
2303 {
2304 if (attackclk >= 14) tile += (extend==2?2:1);
2305 if (attackclk >= 16) tile += (extend==2?2:1);
2306 }
2307 1166 }
2308
2309
2/2
✓ Branch 0 taken 482818 times.
✓ Branch 1 taken 42259 times.
525077 if(useltm)
2310 {
2311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42259 times.
42259 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2312 42259 }
2313
2314 // Stone of Agony
2315
1/2
✓ Branch 0 taken 525077 times.
✗ Branch 1 not taken.
525077 if(agony)
2316 {
2317 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2318 }
2319
2320 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2321
2322 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2323
6/6
✓ Branch 0 taken 137706 times.
✓ Branch 1 taken 387371 times.
✓ Branch 2 taken 134100 times.
✓ Branch 3 taken 3606 times.
✓ Branch 4 taken 11476 times.
✓ Branch 5 taken 126230 times.
525077 if (!(get_bit(quest_rules, qr_HEROFLICKER) && ((superman || hclk) && (frame & 1))))
2324 {
2325 513601 masked_draw(dest);
2326 513601 }
2327
2328 //Prevent flickering -Z
2329
1/2
✓ Branch 0 taken 525077 times.
✗ Branch 1 not taken.
525077 if (!getCanFlicker()) masked_draw(dest);
2330 525077 }
2331
2332
2/2
✓ Branch 0 taken 522223 times.
✓ Branch 1 taken 2876 times.
525099 if(attack!=wHammer)
2333 {
2334 522223 xofs=oxofs;
2335 522223 yofs=oyofs;
2336 522223 return;
2337 }
2338 2876 }
2339
2340
2/2
✓ Branch 0 taken 2876 times.
✓ Branch 1 taken 117470 times.
120346 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2341 {
2342 2876 int32_t wy=1;
2343 2876 int32_t wx=1;
2344 2876 int32_t f=0,t,cs2;
2345 2876 weapon *w=NULL;
2346 2876 bool found = false;
2347
2348
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 2809 times.
2906 for(int32_t i=0; i<Lwpns.Count(); i++)
2349 {
2350 2809 w = (weapon*)Lwpns.spr(i);
2351
2352
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2779 times.
2809 if(w->id == wHammer)
2353 {
2354 2779 found = true;
2355 2779 break;
2356 }
2357 30 }
2358
2359
2/2
✓ Branch 0 taken 2779 times.
✓ Branch 1 taken 97 times.
2876 if(!found)
2360 {
2361
5/10
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 97 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 97 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 97 times.
✗ Branch 9 not taken.
97 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2362 97 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2363 97 found = true;
2364 97 }
2365
2366 2876 t = w->o_tile;
2367 2876 cs2 = w->o_cset;
2368
2369
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 788 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 183 times.
✓ Branch 4 taken 1348 times.
2876 switch(dir)
2370 {
2371 case up:
2372 788 wx=-1;
2373 788 wy=-15;
2374
1/2
✓ Branch 0 taken 788 times.
✗ Branch 1 not taken.
788 if (IsSideSwim())wy+=hammer_swim_up_offset;
2375
2376
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 471 times.
788 if(attackclk>=13)
2377 {
2378 471 wx-=1;
2379 471 wy+=1;
2380 471 ++t;
2381 471 }
2382
2383
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 417 times.
788 if(attackclk>=15)
2384 {
2385
1/2
✓ Branch 0 taken 417 times.
✗ Branch 1 not taken.
417 if (IsSideSwim())wy-=hammer_swim_up_offset;
2386 417 ++t;
2387 417 }
2388
2389 788 break;
2390
2391 case down:
2392 557 wx=3;
2393 557 wy=-14;
2394
1/2
✓ Branch 0 taken 557 times.
✗ Branch 1 not taken.
557 if (IsSideSwim())wy+=hammer_swim_down_offset;
2395 557 t+=3;
2396
2397
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 327 times.
557 if(attackclk>=13)
2398 {
2399 327 wy+=16;
2400 327 ++t;
2401 327 }
2402
2403
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 291 times.
557 if(attackclk>=15)
2404 {
2405 291 wx-=1;
2406 291 wy+=12;
2407
1/2
✓ Branch 0 taken 291 times.
✗ Branch 1 not taken.
291 if (IsSideSwim())wy-=hammer_swim_down_offset;
2408 291 ++t;
2409 291 }
2410
2411 557 break;
2412
2413 case left:
2414 183 wx=0;
2415 183 wy=-14;
2416
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 if (IsSideSwim())wy+=hammer_swim_left_offset;
2417 183 t+=6;
2418 183 f=1;
2419
2420
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 111 times.
183 if(attackclk>=13)
2421 {
2422 111 wx-=7;
2423 111 wy+=8;
2424 111 ++t;
2425 111 }
2426
2427
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 99 times.
183 if(attackclk>=15)
2428 {
2429 99 wx-=8;
2430 99 wy+=8;
2431
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if (IsSideSwim())wy-=hammer_swim_left_offset;
2432 99 ++t;
2433 99 }
2434
2435 183 break;
2436
2437 case right:
2438 1348 wx=0;
2439 1348 wy=-14;
2440
1/2
✓ Branch 0 taken 1348 times.
✗ Branch 1 not taken.
1348 if (IsSideSwim())wy+=hammer_swim_right_offset;
2441 1348 t+=6;
2442
2443
2/2
✓ Branch 0 taken 547 times.
✓ Branch 1 taken 801 times.
1348 if(attackclk>=13)
2444 {
2445 801 wx+=7;
2446 801 wy+=8;
2447 801 ++t;
2448 801 }
2449
2450
2/2
✓ Branch 0 taken 635 times.
✓ Branch 1 taken 713 times.
1348 if(attackclk>=15)
2451 {
2452 713 wx+=8;
2453 713 wy+=8;
2454
1/2
✓ Branch 0 taken 713 times.
✗ Branch 1 not taken.
713 if (IsSideSwim())wy-=hammer_swim_right_offset;
2455 713 ++t;
2456 713 }
2457
2458 1348 break;
2459 }
2460
2461
6/8
✓ Branch 0 taken 2726 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 1927 times.
✓ Branch 3 taken 799 times.
✓ Branch 4 taken 1927 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1927 times.
✗ Branch 7 not taken.
2876 if(BSZ || ((isdungeon() && currscr<128) && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)))
2462 {
2463 150 wy+=2;
2464 150 }
2465
2466 // Stone of Agony
2467
1/2
✓ Branch 0 taken 2876 times.
✗ Branch 1 not taken.
2876 if(agony)
2468 {
2469 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2470 }
2471
2472 2876 w->x = x+wx;
2473 2876 w->y = y+wy-(54-yofs)-fakez;
2474 2876 w->z = (z+zofs);
2475 2876 w->tile = t;
2476 2876 w->flip = f;
2477 2876 w->hxsz=20;
2478 2876 w->hysz=20;
2479
2480
2/2
✓ Branch 0 taken 1531 times.
✓ Branch 1 taken 1345 times.
2876 if(dir>down)
2481 {
2482 1531 w->hysz-=6;
2483 1531 }
2484 else
2485 {
2486 1345 w->hxsz-=6;
2487 1345 w->hyofs=4;
2488 }
2489
2490 2876 w->power = weaponattackpower(itemid);
2491
2492
5/10
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 2781 times.
✓ Branch 2 taken 95 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 95 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 95 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2876 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2493 {
2494
2/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 95 times.
✗ Branch 3 not taken.
95 sfx(((iswaterex(MAPCOMBO(x+wx+8,y+wy), currmap, currscr, -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_bit(quest_rules,qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x.getInt()));
2495 95 }
2496
2497 2876 xofs=oxofs;
2498 2876 yofs=oyofs;
2499 2876 return;
2500 }
2501 117470 }
2502
2/4
✓ Branch 0 taken 5259792 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5259792 times.
5259792 else if(!charging && !spins) // remove the sword
2503 {
2504
2/2
✓ Branch 0 taken 1554709 times.
✓ Branch 1 taken 5259792 times.
6814501 for(int32_t i=0; i<Lwpns.Count(); i++)
2505 {
2506 1554709 weapon *w = (weapon*)Lwpns.spr(i);
2507
2508
6/6
✓ Branch 0 taken 1553966 times.
✓ Branch 1 taken 743 times.
✓ Branch 2 taken 1553856 times.
✓ Branch 3 taken 110 times.
✓ Branch 4 taken 17390 times.
✓ Branch 5 taken 1536466 times.
1554709 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2509 18243 w->dead=1;
2510 1554709 }
2511 5259792 }
2512
2513
2/2
✓ Branch 0 taken 45112 times.
✓ Branch 1 taken 5332150 times.
5377262 if(invisible)
2514 {
2515 45112 xofs=oxofs;
2516 45112 yofs=oyofs;
2517 45112 return;
2518 }
2519
2520
2/4
✓ Branch 0 taken 5332150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5332150 times.
5332150 if(action != casting && action != sideswimcasting)
2521 {
2522 // Keep this consistent with checkspecial2, line 7800-ish...
2523
6/6
✓ Branch 0 taken 138599 times.
✓ Branch 1 taken 5193551 times.
✓ Branch 2 taken 132499 times.
✓ Branch 3 taken 6100 times.
✓ Branch 4 taken 6621 times.
✓ Branch 5 taken 125878 times.
5332150 bool inwater = iswaterex(MAPCOMBO(x+4,y+9), currmap, currscr, -1, x+4, y+9, true, false) && iswaterex(MAPCOMBO(x+4,y+15), currmap, currscr, -1, x+4, y+15, true, false) && iswaterex(MAPCOMBO(x+11,y+9), currmap, currscr, -1, x+11, y+9, true, false) && iswaterex(MAPCOMBO(x+11,y+15), currmap, currscr, -1, x+11, y+15, true, false);
2524
2525 5332150 int32_t jumping2 = int32_t(jumping*((zinit.gravity2 / 100)/16.0));
2526 5332150 bool noliftspr = get_bit(quest_rules,qr_NO_LIFT_SPRITE);
2527 //if (jumping!=0) al_trace("%d %d %f %d\n",jumping,zinit.gravity,zinit.gravity/16.0,jumping2);
2528
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5078236 times.
✓ Branch 3 taken 253914 times.
5332150 switch(zinit.heroAnimationStyle)
2529 {
2530 case las_original: //normal
2531
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 5078172 times.
5078236 if(action==drowning)
2532 {
2533
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(inwater)
2534 {
2535 64 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2537 64 }
2538 else
2539 {
2540 xofs=oxofs;
2541 yofs=oyofs;
2542 return;
2543 }
2544 64 }
2545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5078172 times.
5078172 else if(action==lavadrowning)
2546 {
2547 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2548 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2549 }
2550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5078172 times.
5078172 else if(action==sidedrowning)
2551 {
2552 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2553 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2554 }
2555
2/4
✓ Branch 0 taken 5078172 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5078172 times.
5078172 else if (action == sideswimming || action == sideswimhit)
2556 {
2557 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2558
2559 if(lstep>=6)
2560 {
2561 if(dir==up)
2562 {
2563 if ( script_hero_sprite <= 0 ) ++flip;
2564 }
2565 else
2566 {
2567 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2568 }
2569 }
2570 }
2571
5/6
✓ Branch 0 taken 5014061 times.
✓ Branch 1 taken 64111 times.
✓ Branch 2 taken 5013611 times.
✓ Branch 3 taken 450 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5013611 times.
5078172 else if(action==swimming || action==swimhit || hopclk==0xFF)
2572 {
2573 64561 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2574
2575
2/2
✓ Branch 0 taken 32239 times.
✓ Branch 1 taken 32322 times.
64561 if(lstep>=6)
2576 {
2577
2/2
✓ Branch 0 taken 6500 times.
✓ Branch 1 taken 25822 times.
32322 if(dir==up)
2578 {
2579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6500 times.
6500 if ( script_hero_sprite <= 0 ) ++flip;
2580 6500 }
2581 else
2582 {
2583
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25822 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25822 times.
25822 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2584 }
2585 32322 }
2586
2587
2/2
✓ Branch 0 taken 61852 times.
✓ Branch 1 taken 2709 times.
64561 if(isDiving())
2588 {
2589 2709 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2709 times.
2709 if ( script_hero_sprite <= 0 ) tile+=((frame>>3) & 1)*(extend==2?2:1);
2591 2709 }
2592 64561 }
2593
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 5011993 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
5013611 else if(charging > 0 && attack != wHammer)
2594 {
2595 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2596
2597
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2598 {
2599
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2600 {
2601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( script_hero_sprite <= 0 ) ++flip;
2602 144 }
2603 else
2604 {
2605
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2606 }
2607 675 }
2608 1618 }
2609
9/12
✓ Branch 0 taken 5011751 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 5011751 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 85805 times.
✓ Branch 5 taken 4926188 times.
✓ Branch 6 taken 71761 times.
✓ Branch 7 taken 14044 times.
✓ Branch 8 taken 71761 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 71761 times.
5011993 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0 && action!=rafting)
2610 {
2611 71761 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71761 times.
71761 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2613 71761 }
2614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4940232 times.
4940232 else if(fallclk>0)
2615 {
2616 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2617 if ( script_hero_sprite <= 0 ) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2618 }
2619
3/6
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 4939616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 616 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4940232 else if(!noliftspr&&action==lifting&&isLifting())
2620 {
2621 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2622 if(script_hero_sprite <= 0)
2623 {
2624 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2625 auto speed = tliftclk/frames;
2626 if (speed < 1) speed = 1;
2627 auto curframe = (tliftclk - liftclk) / speed;
2628 if (!tliftclk) curframe = frames - 1;
2629 if(unsigned(curframe) < frames)
2630 tile += curframe * (extend == 2 ? 2 : 1);
2631 }
2632 }
2633 else
2634 {
2635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4940232 times.
4940232 if(IsSideSwim())
2636 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2637
3/4
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 4939616 times.
✓ Branch 2 taken 616 times.
✗ Branch 3 not taken.
4940232 else if(!noliftspr&&isLifting())
2638 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2639 4940232 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2640
2641
2/2
✓ Branch 0 taken 3714320 times.
✓ Branch 1 taken 1225912 times.
4940232 if(dir>up)
2642 {
2643 3714320 useltm=true;
2644 3714320 shieldModify=true;
2645 3714320 }
2646
2647
2/2
✓ Branch 0 taken 2400485 times.
✓ Branch 1 taken 2539747 times.
4940232 if(lstep>=6)
2648 {
2649
2/2
✓ Branch 0 taken 623117 times.
✓ Branch 1 taken 1916630 times.
2539747 if(dir==up)
2650 {
2651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 623117 times.
623117 if ( script_hero_sprite <= 0 ) ++flip;
2652 623117 }
2653 else
2654 {
2655
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1916630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1916630 times.
1916630 if ( script_hero_sprite <= 0 ) extend==2?tile+=2:++tile;
2656 }
2657 2539747 }
2658 }
2659
2660 5078236 break;
2661
2662 case las_bszelda: //BS
2663
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 253274 times.
253914 if(action==drowning)
2664 {
2665
1/2
✓ Branch 0 taken 640 times.
✗ Branch 1 not taken.
640 if(inwater)
2666 {
2667 640 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
640 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2669 640 }
2670 else
2671 {
2672 xofs=oxofs;
2673 yofs=oyofs;
2674 return;
2675 }
2676 640 }
2677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253274 times.
253274 else if (action == sidedrowning)
2678 {
2679 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2680 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2681 }
2682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 253274 times.
253274 else if(action==lavadrowning)
2683 {
2684 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2685 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2686 }
2687
2/4
✓ Branch 0 taken 253274 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 253274 times.
253274 else if (action == sideswimming || action == sideswimhit)
2688 {
2689 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2690
2691 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2692 }
2693
4/6
✓ Branch 0 taken 251812 times.
✓ Branch 1 taken 1462 times.
✓ Branch 2 taken 251812 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 251812 times.
253274 else if(action==swimming || action==swimhit || hopclk==0xFF)
2694 {
2695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
1462 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2696 {
2697 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2698 }
2699 else
2700 {
2701 1462 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2702 }
2703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1462 times.
1462 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2704
2705
2/2
✓ Branch 0 taken 1323 times.
✓ Branch 1 taken 139 times.
1462 if(isDiving())
2706 {
2707
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if (get_bit(quest_rules, qr_COPIED_SWIM_SPRITES))
2708 {
2709 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2710 }
2711 else
2712 {
2713 139 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2714 }
2715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2716 139 }
2717 1462 }
2718
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 251812 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
251812 else if(charging > 0 && attack != wHammer)
2719 {
2720 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2721 if ( script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2722 }
2723
8/10
✓ Branch 0 taken 248697 times.
✓ Branch 1 taken 3115 times.
✓ Branch 2 taken 248697 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2455 times.
✓ Branch 5 taken 249357 times.
✓ Branch 6 taken 1994 times.
✓ Branch 7 taken 461 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1994 times.
251812 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2724 {
2725 1994 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1994 times.
1994 if ( script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2727 1994 }
2728
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 249608 times.
249818 else if(fallclk>0)
2729 {
2730 210 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if ( script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2732 210 }
2733
5/6
✓ Branch 0 taken 25575 times.
✓ Branch 1 taken 224033 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 25466 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 109 times.
249608 else if(!noliftspr&&action==lifting&&isLifting())
2734 {
2735 109 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(script_hero_sprite <= 0)
2737 {
2738 109 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2739 109 auto speed = tliftclk/frames;
2740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (speed < 1) speed = 1;
2741 109 auto curframe = (tliftclk - liftclk) / speed;
2742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (!tliftclk) curframe = frames - 1;
2743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(unsigned(curframe) < frames)
2744 109 tile += curframe * (extend == 2 ? 2 : 1);
2745 109 }
2746 109 }
2747 else
2748 {
2749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249499 times.
249499 if(IsSideSwim())
2750 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2751
4/4
✓ Branch 0 taken 25466 times.
✓ Branch 1 taken 224033 times.
✓ Branch 2 taken 25073 times.
✓ Branch 3 taken 393 times.
249499 else if(!noliftspr&&isLifting())
2752 393 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2753 249106 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2754
2755
2/2
✓ Branch 0 taken 79914 times.
✓ Branch 1 taken 169585 times.
249499 if(dir>up)
2756 {
2757 169585 useltm=true;
2758 169585 shieldModify=true;
2759 169585 }
2760
2761 /*
2762 else if (dir==up)
2763 {
2764 useltm=true;
2765 }
2766 */
2767
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 246939 times.
249499 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2768 }
2769
2770 253914 break;
2771
2772 case las_zelda3slow: //8-frame Zelda 3 (slow)
2773 case las_zelda3: //8-frame Zelda 3
2774 if(action == drowning)
2775 {
2776 if(inwater)
2777 {
2778 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2779 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2780 }
2781 else
2782 {
2783 xofs=oxofs;
2784 yofs=oyofs;
2785 return;
2786 }
2787 }
2788 else if(action == lavadrowning)
2789 {
2790 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2791 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2792
2793 }
2794 else if(action == sidedrowning)
2795 {
2796 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2797 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2798 }
2799 else if (action == sideswimming || action == sideswimhit)
2800 {
2801 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2802
2803 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2804 }
2805 else if(action == swimming || action==swimhit || hopclk==0xFF)
2806 {
2807 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2808 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2809
2810 if(isDiving())
2811 {
2812 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2813 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
2814 }
2815 }
2816 else if(charging > 0 && attack != wHammer)
2817 {
2818 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2819 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
2820 //int32_t l=hero_count/hero_animation_speed;
2821 int32_t l=(hero_count/hero_animation_speed)&15;
2822 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
2823 l-=((l>3)?1:0)+((l>12)?1:0);
2824 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
2825 }
2826 else if((z>0 || fakez>0 || isSideViewHero()) && jumping2>0 && jumping2<24 && game->get_life()>0)
2827 {
2828 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2829 if (script_hero_sprite <= 0 ) tile+=((int32_t)jumping2/8)*(extend==2?2:1);
2830 }
2831 else if(fallclk>0)
2832 {
2833 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2834 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2835 }
2836 else if(!noliftspr&&action==lifting&&isLifting())
2837 {
2838 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2839 if(script_hero_sprite <= 0)
2840 {
2841 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2842 auto speed = tliftclk/frames;
2843 if (speed < 1) speed = 1;
2844 auto curframe = (tliftclk-liftclk)/speed;
2845 if (!tliftclk) curframe = frames - 1;
2846 if(unsigned(curframe) < frames)
2847 tile += curframe * (extend == 2 ? 2 : 1);
2848 }
2849 }
2850 else
2851 {
2852 if(IsSideSwim())
2853 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2854 else if(!noliftspr&&isLifting())
2855 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2856 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2857
2858 if(action == walking || action == climbcoverbottom || action == climbcovertop)
2859 {
2860 if (script_hero_sprite <= 0 ) tile += (extend == 2 ? 2 : 1);
2861 }
2862
2863 if(dir>up)
2864 {
2865 useltm=true;
2866 shieldModify=true;
2867 }
2868
2869 if(action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop)
2870 {
2871 //tile+=(extend==2?2:1);
2872 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
2873 int32_t l = hero_count / hero_animation_speed;
2874 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
2875 if (script_hero_sprite <= 0 ) tile += (l / 2) * (extend == 2 ? 2 : 1);
2876 }
2877 }
2878
2879 break;
2880
2881 default:
2882 break;
2883 }
2884 5332150 }
2885
2886
6/6
✓ Branch 0 taken 4630725 times.
✓ Branch 1 taken 701425 times.
✓ Branch 2 taken 2937152 times.
✓ Branch 3 taken 1693573 times.
✓ Branch 4 taken 145666 times.
✓ Branch 5 taken 2791486 times.
5332150 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2887
2888
2/2
✓ Branch 0 taken 5330314 times.
✓ Branch 1 taken 1836 times.
5332150 if(action==won)
2889 {
2890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1836 times.
1836 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
2891 1836 }
2892
2893
4/4
✓ Branch 0 taken 5294580 times.
✓ Branch 1 taken 37570 times.
✓ Branch 2 taken 36751 times.
✓ Branch 3 taken 5257829 times.
5332150 if(action==landhold1 || action==landhold2)
2894 {
2895 74321 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2896
6/6
✓ Branch 0 taken 62873 times.
✓ Branch 1 taken 11448 times.
✓ Branch 2 taken 46508 times.
✓ Branch 3 taken 16365 times.
✓ Branch 4 taken 13567 times.
✓ Branch 5 taken 32941 times.
74321 yofs = oyofs-((!BSZ && isdungeon() && currscr<128 && !get_bit(quest_rules,qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2897 74321 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
2898 74321 }
2899
4/4
✓ Branch 0 taken 5257179 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 5257049 times.
5257829 else if(action==waterhold1 || action==waterhold2)
2900 {
2901 780 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2902 780 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
2903 780 }
2904
2/4
✓ Branch 0 taken 5257049 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5257049 times.
5257049 else if(action==sidewaterhold1 || action==sidewaterhold2)
2905 {
2906 useltm=(get_bit(quest_rules,qr_EXPANDEDLTM) != 0);
2907 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
2908 }
2909
2910
2/4
✓ Branch 0 taken 5332150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5332150 times.
5332150 if(action!=casting && action!=sideswimcasting)
2911 {
2912
2/2
✓ Branch 0 taken 1285503 times.
✓ Branch 1 taken 4046647 times.
5332150 if(useltm)
2913 {
2914
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 4044087 times.
4046647 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
2915 4046647 }
2916 5332150 }
2917
2918 // Stone of Agony
2919
2/2
✓ Branch 0 taken 5332118 times.
✓ Branch 1 taken 32 times.
5332150 if(agony)
2920 {
2921
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2922 32 }
2923
2924
6/6
✓ Branch 0 taken 1163356 times.
✓ Branch 1 taken 4168794 times.
✓ Branch 2 taken 1108839 times.
✓ Branch 3 taken 54517 times.
✓ Branch 4 taken 59060 times.
✓ Branch 5 taken 1104296 times.
5332150 if(!(get_bit(quest_rules,qr_HEROFLICKER)&&((superman||hclk)&&(frame&1))))
2925 {
2926 5273090 masked_draw(dest);
2927 5273090 }
2928
2929 //draw held items after Hero so they don't go behind his head
2930
4/4
✓ Branch 0 taken 5294580 times.
✓ Branch 1 taken 37570 times.
✓ Branch 2 taken 36751 times.
✓ Branch 3 taken 5257829 times.
5332150 if(action==landhold1 || action==landhold2)
2931 {
2932
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 74311 times.
74321 if(holditem > -1)
2933 {
2934
2/2
✓ Branch 0 taken 41752 times.
✓ Branch 1 taken 32559 times.
74311 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2935 {
2936 41752 putitem2(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2937 41752 }
2938 else
2939 {
2940 32559 putitem(dest,x-((action==landhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2941 }
2942 74311 }
2943 74321 }
2944
4/4
✓ Branch 0 taken 5257179 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 5257049 times.
5257829 else if(action==waterhold1 || action==waterhold2)
2945 {
2946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780 times.
780 if(holditem > -1)
2947 {
2948
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 260 times.
780 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2949 {
2950 520 putitem2(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2951 520 }
2952 else
2953 {
2954 260 putitem(dest,x-((action==waterhold1)?4:0),y+yofs-12-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2955 }
2956 780 }
2957 780 }
2958
2/4
✓ Branch 0 taken 5257049 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5257049 times.
5257049 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
2959 {
2960 if(holditem > -1)
2961 {
2962 if(get_bit(quest_rules,qr_HOLDITEMANIMATION))
2963 {
2964 putitem2(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
2965 }
2966 else
2967 {
2968 putitem(dest,x-((action==sidewaterhold1)?4:0),y+yofs-16-(get_bit(quest_rules, qr_NOITEMOFFSET))-fakez-z,holditem);
2969 }
2970 }
2971 }
2972
4/4
✓ Branch 0 taken 14944 times.
✓ Branch 1 taken 5317206 times.
✓ Branch 2 taken 3393 times.
✓ Branch 3 taken 11551 times.
5332150 if(fairyclk==0||(get_bit(quest_rules,qr_NOHEARTRING)))
2973 {
2974 5320599 xofs=oxofs;
2975 5320599 yofs=oyofs;
2976 5320599 return;
2977 }
2978
2979 11551 double a2 = fairyclk*int64_t(2)*PI/80 + (PI/2);
2980 11551 int32_t hearts=0;
2981 // int32_t htile = QHeader.dat_flags[ZQ_TILES] ? 2 : 0;
2982 11551 int32_t htile = 2;
2983
2984 11551 do
2985 {
2986 72528 int32_t nx=125;
2987
2988
2/2
✓ Branch 0 taken 51168 times.
✓ Branch 1 taken 21360 times.
72528 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2989 {
2990 21360 nx=x;
2991 21360 }
2992
2993 72528 int32_t ny=88;
2994
2995
2/2
✓ Branch 0 taken 51168 times.
✓ Branch 1 taken 21360 times.
72528 if(get_bit(quest_rules,qr_HEARTRINGFIX))
2996 {
2997 21360 ny=y;
2998 21360 }
2999
3000 72528 double tx = zc::math::Cos(a2)*53 +nx;
3001 72528 double ty = -zc::math::Sin(a2)*53 +ny+playing_field_offset;
3002 72528 overtile8(dest,htile,int32_t(tx),int32_t(ty),1,0);
3003 72528 a2-=PI/4;
3004 72528 ++hearts;
3005
2/2
✓ Branch 0 taken 60977 times.
✓ Branch 1 taken 11551 times.
145056 }
3006
2/2
✓ Branch 0 taken 5680 times.
✓ Branch 1 taken 66848 times.
72528 while(a2>PI/2 && hearts<8);
3007
3008 11551 xofs=oxofs;
3009 11551 yofs=oyofs;
3010 5903921 }
3011
3012 5786691 void HeroClass::masked_draw(BITMAP* dest)
3013 {
3014
12/12
✓ Branch 0 taken 3256285 times.
✓ Branch 1 taken 2530406 times.
✓ Branch 2 taken 3099971 times.
✓ Branch 3 taken 156314 times.
✓ Branch 4 taken 3057273 times.
✓ Branch 5 taken 42698 times.
✓ Branch 6 taken 3010898 times.
✓ Branch 7 taken 46375 times.
✓ Branch 8 taken 2945917 times.
✓ Branch 9 taken 64981 times.
✓ Branch 10 taken 2997670 times.
✓ Branch 11 taken 102301 times.
5786691 if(isdungeon() && currscr<128 && (x<16 || x>224 || y<18 || y>146) && !get_bit(quest_rules,qr_FREEFORM))
3015 {
3016 // clip under doorways
3017 102301 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
3018
3019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102301 times.
102301 if(sub!=NULL)
3020 {
3021 102301 yofs -= (playing_field_offset+16);
3022 102301 xofs -= 16;
3023 102301 sprite::draw(sub);
3024
1/2
✓ Branch 0 taken 102301 times.
✗ Branch 1 not taken.
102301 if(lift_wpn)
3025 {
3026 handle_lift(false);
3027 bool shad = lift_wpn->has_shadow;
3028 lift_wpn->has_shadow = false;
3029 lift_wpn->draw(sub);
3030 lift_wpn->has_shadow = shad;
3031 }
3032 102301 prompt_draw(sub);
3033 102301 xofs+=16;
3034 102301 yofs += (playing_field_offset+16);
3035 102301 destroy_bitmap(sub);
3036 102301 }
3037 102301 }
3038 else
3039 {
3040 5684390 sprite::draw(dest);
3041
2/2
✓ Branch 0 taken 5683888 times.
✓ Branch 1 taken 502 times.
5684390 if(lift_wpn)
3042 {
3043 502 handle_lift(false);
3044 502 bool shad = lift_wpn->has_shadow;
3045 502 lift_wpn->has_shadow = false;
3046 502 lift_wpn->draw(dest);
3047 502 lift_wpn->has_shadow = shad;
3048 502 }
3049 5684390 prompt_draw(dest);
3050 }
3051
3052 5786691 return;
3053 }
3054 5786691 void HeroClass::prompt_draw(BITMAP* dest)
3055 {
3056
2/2
✓ Branch 0 taken 5784642 times.
✓ Branch 1 taken 2049 times.
5786691 if(!prompt_combo) return;
3057 2049 int32_t sx = real_x(x+xofs+prompt_x);
3058 2049 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3059 2049 sy -= fake_z(fakez);
3060 2049 overcombo(dest, sx, sy, prompt_combo, prompt_cset);
3061 2049 return;
3062 5786691 }
3063
3064 7568 void collectitem_script(int32_t id)
3065 {
3066
2/2
✓ Branch 0 taken 7469 times.
✓ Branch 1 taken 99 times.
7568 if(itemsbuf[id].collect_script)
3067 {
3068 //clear item script stack.
3069 //ri = &(itemScriptData[id]);
3070 //ri->Clear();
3071 //itemCollectScriptData[id].Clear();
3072 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0;
3073 99 ri = &(itemCollectScriptData[id]);
3074
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 99 times.
101475 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id][q] = 0xFFFF;
3075 99 ri->Clear();
3076 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id & 0xFFF)*-1));
3077
3078
2/6
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
99 if ( id > 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3079 {
3080 99 item_collect_doscript[id] = 1;
3081 99 itemscriptInitialised[id] = 0;
3082 99 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, ((id)*-1));
3083 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3084 99 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id));
3085 99 }
3086 else if (id == 0 && !(item_collect_doscript[id] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3087 {
3088 item_collect_doscript[id] = 1;
3089 itemscriptInitialised[id] = 0;
3090 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
3091 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
3092 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
3093 }
3094 //runningItemScripts[id] = 0;
3095 99 }
3096 7568 }
3097 759 void passiveitem_script(int32_t id, bool doRun = false)
3098 {
3099 //Passive item scripts on colelction
3100
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 734 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
759 if(itemsbuf[id].script && ( (itemsbuf[id].flags&ITEM_PASSIVESCRIPT) && (get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING)) ))
3101 {
3102 ri = &(itemScriptData[id]);
3103 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id][q] = 0xFFFF;
3104 ri->Clear();
3105 item_doscript[id] = 1;
3106 itemscriptInitialised[id] = 0;
3107
3108
3109 if(get_bit(quest_rules,qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3110 && current_item(itemsbuf[id].family) > itemsbuf[id].fam_type)
3111 {
3112 item_doscript[id] = 0;
3113 return;
3114 }
3115 if(doRun)
3116 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id].script, id);
3117 }
3118 759 }
3119
3120 // separate case for sword/wand/hammer/slashed weapons only
3121 // the main weapon checking is in the global function check_collisions()
3122 5152186 bool HeroClass::checkstab()
3123 {
3124
14/14
✓ Branch 0 taken 4518895 times.
✓ Branch 1 taken 633291 times.
✓ Branch 2 taken 159076 times.
✓ Branch 3 taken 474215 times.
✓ Branch 4 taken 142342 times.
✓ Branch 5 taken 16734 times.
✓ Branch 6 taken 139466 times.
✓ Branch 7 taken 2876 times.
✓ Branch 8 taken 139438 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 127896 times.
✓ Branch 11 taken 11542 times.
✓ Branch 12 taken 147287 times.
✓ Branch 13 taken 358108 times.
5152186 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3125 633291 || (attackclk<=4))
3126 4794078 return false;
3127
3128 358108 weapon *w=NULL;
3129
3130 358108 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3131 358108 bool found = false;
3132 358108 int32_t melee_weapon_index = 0;
3133 358108 int32_t parentitem=-1;
3134 358108 weapon* meleeweap = nullptr;
3135
2/2
✓ Branch 0 taken 39423 times.
✓ Branch 1 taken 422978 times.
462401 for(int32_t i=0; i<Lwpns.Count(); i++)
3136 {
3137 422978 w = (weapon*)Lwpns.spr(i);
3138
3139
6/6
✓ Branch 0 taken 422940 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 10433 times.
✓ Branch 3 taken 412507 times.
✓ Branch 4 taken 104293 times.
✓ Branch 5 taken 318685 times.
422978 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3140 {
3141 318685 found = true;
3142 318685 melee_weapon_index = i+1;
3143 318685 meleeweap = w;
3144 // Position the sword as Hero slashes with it.
3145
3/4
✓ Branch 0 taken 316197 times.
✓ Branch 1 taken 2488 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 316197 times.
318685 if(w->id!=wHammer&&w->id!=wBugNet)
3146 316197 positionSword(w,w->parentitem);
3147
3148 318685 wx=w->x;
3149 318685 wy=w->y;
3150 318685 wz=w->z;
3151 318685 wxsz = w->hxsz;
3152 318685 wysz = w->hysz;
3153 318685 parentitem = w->parentitem;
3154 318685 break;
3155 }
3156 104293 }
3157
3158
6/6
✓ Branch 0 taken 335752 times.
✓ Branch 1 taken 22356 times.
✓ Branch 2 taken 34782 times.
✓ Branch 3 taken 300970 times.
✓ Branch 4 taken 1806 times.
✓ Branch 5 taken 32976 times.
358108 if(attack==wSword && attackclk>=14 && charging==0)
3159 32976 return false;
3160
3161
2/2
✓ Branch 0 taken 285709 times.
✓ Branch 1 taken 39423 times.
325132 if(!found)
3162 39423 return false;
3163
3164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285709 times.
285709 if(attack == wFire)
3165 return false;
3166
3167
2/2
✓ Branch 0 taken 283221 times.
✓ Branch 1 taken 2488 times.
285709 if(attack==wHammer)
3168 {
3169
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 1520 times.
2488 if(attackclk<15)
3170 {
3171
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 53 times.
✓ Branch 4 taken 455 times.
968 switch(w->dir)
3172 {
3173 case up:
3174 260 wx=x-1;
3175 260 wy=y-4;
3176 260 break;
3177
3178 case down:
3179 200 wx=x+8;
3180 200 wy=y+28;
3181 200 break; // This is consistent with 2.10
3182
3183 case left:
3184 53 wx=x-13;
3185 53 wy=y+14;
3186 53 break;
3187
3188 case right:
3189 455 wx=x+21;
3190 455 wy=y+14;
3191 455 break;
3192 }
3193
3194
5/8
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 873 times.
✓ Branch 2 taken 95 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 95 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 95 times.
968 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3195 {
3196 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3197 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3198 switch(dir)
3199 {
3200 case up:
3201 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3202 break;
3203
3204 case down:
3205 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3206 break;
3207
3208 case left:
3209 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3210 break;
3211
3212 case right:
3213 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3214 break;
3215 }
3216 */
3217 95 }
3218
3219 968 return false;
3220 }
3221
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 95 times.
1520 else if(attackclk==15)
3222 {
3223 // Hammer's reach needs adjusted slightly for backward compatibility
3224
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 26 times.
95 if(w->dir==up)
3225 26 w->hyofs-=1;
3226
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 5 times.
69 else if(w->dir==left)
3227 5 w->hxofs-=2;
3228 95 }
3229 1520 }
3230
3231 // The return of Spaghetti Code Constants!
3232
6/6
✓ Branch 0 taken 10709 times.
✓ Branch 1 taken 274032 times.
✓ Branch 2 taken 272494 times.
✓ Branch 3 taken 1538 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 1520 times.
284741 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3233
3/4
✓ Branch 0 taken 17374 times.
✓ Branch 1 taken 267367 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17374 times.
284741 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
3234 284741 itemid = vbound(itemid, 0, MAXITEMS-1);
3235
3236 // The sword offsets aren't based on anything other than what felt about right
3237 // compared to the NES game and what mostly kept it from hitting things that
3238 // should clearly be out of range. They could probably still use more tweaking.
3239 // Don't use 2.10 for reference; it's pretty far off.
3240 // - Saf
3241
3242
6/6
✓ Branch 0 taken 34454 times.
✓ Branch 1 taken 250287 times.
✓ Branch 2 taken 5420 times.
✓ Branch 3 taken 29034 times.
✓ Branch 4 taken 8227 times.
✓ Branch 5 taken 26227 times.
284741 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & ITEM_FLAG4)
3243 {
3244
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4253 times.
✓ Branch 2 taken 6662 times.
✓ Branch 3 taken 7800 times.
✓ Branch 4 taken 7512 times.
26227 switch(w->dir)
3245 {
3246 case up:
3247
2/2
✓ Branch 0 taken 2745 times.
✓ Branch 1 taken 1508 times.
4253 if(attackclk<8)
3248 {
3249 1508 wy-=4;
3250 1508 }
3251
3252 4253 break;
3253
3254 case down:
3255 //if(attackclk<8)
3256 {
3257 6662 wy-=2;
3258 }
3259 6662 break;
3260
3261 case left:
3262
3263 //if(attackclk<8)
3264 {
3265 7800 wx+=2;
3266 }
3267
3268 7800 break;
3269
3270 case right:
3271
3272 //if(attackclk<8)
3273 {
3274 7512 wx-=3;
3275 //wy+=((spins>0 || get_bit(quest_rules, qr_SLASHFLIPFIX)) ? -4 : 4);
3276 }
3277
3278 7512 break;
3279 }
3280 26227 }
3281
3282
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 63799 times.
✓ Branch 2 taken 61828 times.
✓ Branch 3 taken 78625 times.
✓ Branch 4 taken 80489 times.
284741 switch(w->dir)
3283 {
3284 case up:
3285 63799 wx+=2;
3286 63799 break;
3287
3288 case down:
3289 61828 break;
3290
3291 case left:
3292 78625 wy-=3;
3293 78625 break;
3294
3295 case right:
3296 80489 wy-=3;
3297 80489 break;
3298 }
3299
3300 284741 wx+=w->hxofs;
3301 284741 wy+=w->hyofs;
3302 284741 wy-=(w->fakez).getInt();
3303
3304
2/2
✓ Branch 0 taken 281989 times.
✓ Branch 1 taken 1465381 times.
1747370 for(int32_t i=0; i<guys.Count(); i++)
3305 {
3306
1/2
✓ Branch 0 taken 1465381 times.
✗ Branch 1 not taken.
1465381 if(attack==wBugNet) break;
3307 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3308
6/6
✓ Branch 0 taken 29455 times.
✓ Branch 1 taken 1435926 times.
✓ Branch 2 taken 29044 times.
✓ Branch 3 taken 411 times.
✓ Branch 4 taken 28940 times.
✓ Branch 5 taken 104 times.
1465409 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3309
5/6
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 1351827 times.
✓ Branch 3 taken 84387 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1436214 times.
1436441 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & ITEM_FLAG3))
3310
4/4
✓ Branch 0 taken 5332 times.
✓ Branch 1 taken 1430882 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 5304 times.
1436214 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & ITEM_FLAG3)))
3311 {
3312 // Checking the whimsical ring for every collision check causes
3313 // an odd bug. It's much more likely to activate on a 0-damage
3314 // weapon, since a 0-damage hit won't make the enemy invulnerable
3315 // to damaging hits in the following frames.
3316
3317 29171 int32_t whimsyid = current_item_id(itype_whimsicalring);
3318
3319 29171 int32_t dmg = weaponattackpower(itemid);
3320
2/2
✓ Branch 0 taken 27260 times.
✓ Branch 1 taken 1911 times.
29171 if(whimsyid>-1)
3321 {
3322
3/4
✓ Branch 0 taken 1911 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1795 times.
✓ Branch 3 taken 116 times.
1911 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3323 116 dmg += current_item_power(itype_whimsicalring);
3324 1795 else whimsyid = -1;
3325 1911 }
3326 29171 int32_t atkringid = current_item_id(itype_atkring);
3327
2/2
✓ Branch 0 taken 29161 times.
✓ Branch 1 taken 10 times.
29171 if(atkringid>-1)
3328 {
3329 10 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3330 10 dmg += itemsbuf[atkringid].misc1; //Additive
3331 10 }
3332
3333 29171 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn,w);
3334 29171 enemy *e = (enemy*)guys.spr(i);
3335
2/2
✓ Branch 0 taken 10599 times.
✓ Branch 1 taken 18572 times.
29171 if (h == -1) { e->hitby[HIT_BY_LWEAPON] = melee_weapon_index; } //temp_hit = true; }
3336 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3337
3338
4/4
✓ Branch 0 taken 18572 times.
✓ Branch 1 taken 10599 times.
✓ Branch 2 taken 18527 times.
✓ Branch 3 taken 45 times.
29171 if(h<0 && whimsyid>-1)
3339 {
3340 45 sfx(itemsbuf[whimsyid].usesound);
3341 45 }
3342
3343
4/4
✓ Branch 0 taken 25007 times.
✓ Branch 1 taken 4164 times.
✓ Branch 2 taken 24913 times.
✓ Branch 3 taken 94 times.
29171 if(h && charging>0)
3344 {
3345 94 attackclk = SWORDTAPFRAME;
3346 94 spins=0;
3347 94 }
3348
3349
8/8
✓ Branch 0 taken 25007 times.
✓ Branch 1 taken 4164 times.
✓ Branch 2 taken 21314 times.
✓ Branch 3 taken 3693 times.
✓ Branch 4 taken 21311 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 21301 times.
29171 if(h && hclk==0 && inlikelike != 1 && !get_bit(quest_rules, qr_DYING_ENEMIES_IGNORE_STUN))
3350 {
3351
2/2
✓ Branch 0 taken 21235 times.
✓ Branch 1 taken 66 times.
21301 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3352 {
3353 66 hithero(i);
3354 66 }
3355 21301 }
3356
3357
2/2
✓ Branch 0 taken 26415 times.
✓ Branch 1 taken 2756 times.
29171 if(h==2)
3358 2756 break;
3359 26415 }
3360 1462629 }
3361
3362
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 284719 times.
569486 if(attack == wBugNet
3363
3/4
✓ Branch 0 taken 284741 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 284741 times.
284745 || (parentitem==-1&&!get_bit(quest_rules,qr_NOITEMMELEE))
3364
1/2
✓ Branch 0 taken 284741 times.
✗ Branch 1 not taken.
284741 || (parentitem>-1&&!(itemsbuf[parentitem].flags & ITEM_FLAG7)))
3365 {
3366
1/4
✓ Branch 0 taken 284723 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
284723 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3367
2/2
✓ Branch 0 taken 284723 times.
✓ Branch 1 taken 71715 times.
356438 for(int32_t j=0; j<items.Count(); j++)
3368 {
3369 71715 item* ptr = (item*)items.spr(j);
3370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71715 times.
71715 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].family == itype_fairy)
3371 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & ITEM_FLAG1));
3372
3373
2/4
✓ Branch 0 taken 71715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71715 times.
✗ Branch 3 not taken.
71715 if((itemsbuf[ptr->id].family == itype_bottlefill || dofairy) && !game->canFillBottle())
3374 continue; //No picking these up unless you have a bottle to fill!
3375
5/6
✓ Branch 0 taken 71688 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 12626 times.
✓ Branch 3 taken 59062 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12626 times.
71715 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3376 {
3377
7/8
✓ Branch 0 taken 59062 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 22938 times.
✓ Branch 3 taken 36124 times.
✓ Branch 4 taken 36151 times.
✓ Branch 5 taken 22938 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 36151 times.
59089 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3378 {
3379
6/6
✓ Branch 0 taken 34240 times.
✓ Branch 1 taken 1911 times.
✓ Branch 2 taken 841 times.
✓ Branch 3 taken 33399 times.
✓ Branch 4 taken 34240 times.
✓ Branch 5 taken 1911 times.
70391 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3380
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 34080 times.
✓ Branch 3 taken 160 times.
34240 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3381 {
3382 1911 int32_t pickup = ptr->pickup;
3383 1911 int32_t id2 = ptr->id;
3384 1911 int32_t pstr = ptr->pstring;
3385 1911 int32_t pstr_flags = ptr->pickup_string_flags;
3386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1911 times.
1911 if(!dofairy)
3387 {
3388 1911 std::vector<int32_t> &ev = FFCore.eventData;
3389 1911 ev.clear();
3390 1911 ev.push_back(id2*10000);
3391 1911 ev.push_back(pickup*10000);
3392 1911 ev.push_back(pstr*10000);
3393 1911 ev.push_back(pstr_flags*10000);
3394 1911 ev.push_back(0);
3395 1911 ev.push_back(ptr->getUID());
3396 1911 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3397 1911 ev.push_back(w->getUID());
3398
3399 1911 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3400 1911 bool nullify = ev[4] != 0;
3401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1911 times.
1911 if(nullify) continue;
3402 1911 id2 = ev[0]/10000;
3403 1911 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3404 1911 pstr = ev[2] / 10000;
3405 1911 pstr_flags = ev[3] / 10000;
3406 1911 }
3407
3408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1911 times.
1911 if(pickup&ipONETIME) // set mITEM for one-time-only items
3409 setmapflag(mITEM);
3410
1/2
✓ Branch 0 taken 1911 times.
✗ Branch 1 not taken.
1911 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3411 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3412
3413
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1911 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1911 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3414 setxmapflag(1<<ptr->pickupexstate);
3415
1/2
✓ Branch 0 taken 1911 times.
✗ Branch 1 not taken.
1911 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3416 {
3417 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
3418 hidden_entrance(0, true, false, -5);
3419 }
3420 //!DIMI
3421
3422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1911 times.
1911 if(dofairy)
3423 {
3424 game->fillBottle(itemsbuf[ptr->id].misc4);
3425 }
3426 else
3427 {
3428 1911 collectitem_script(id2);
3429
3430 1911 getitem(id2, false, true);
3431 }
3432 1911 items.del(j);
3433
3434
2/2
✓ Branch 0 taken 2458 times.
✓ Branch 1 taken 1911 times.
4369 for(int32_t i=0; i<Lwpns.Count(); i++)
3435 {
3436 2458 weapon *w2 = (weapon*)Lwpns.spr(i);
3437
3438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2458 times.
2458 if(w2->dragging==j)
3439 {
3440 w2->dragging=-1;
3441 }
3442
1/2
✓ Branch 0 taken 2458 times.
✗ Branch 1 not taken.
2458 else if(w2->dragging>j)
3443 {
3444 w2->dragging-=1;
3445 }
3446 2458 }
3447
3448
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1911 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1911 if ( (pstr > 0 && pstr < msg_count) )
3449 {
3450 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3451 {
3452 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3453 FFCore.SetItemMessagePlayed(id2);
3454 donewmsg(pstr);
3455 break;
3456 }
3457 }
3458
3459 1911 --j;
3460 1911 }
3461 36151 }
3462 59089 }
3463 71715 }
3464 284723 }
3465
3466
3/4
✓ Branch 0 taken 284723 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 284723 times.
284745 if(attack==wCByrna || attack==wBugNet)
3467 22 return false;
3468
3469
2/2
✓ Branch 0 taken 272494 times.
✓ Branch 1 taken 12229 times.
284723 if(attack==wSword)
3470 {
3471
2/2
✓ Branch 0 taken 238600 times.
✓ Branch 1 taken 33894 times.
272494 if(attackclk == 6)
3472 {
3473
2/2
✓ Branch 0 taken 5965344 times.
✓ Branch 1 taken 33894 times.
5999238 for(int32_t q=0; q<176; q++)
3474 {
3475 5965344 set_bit(screengrid,q,0);
3476 5965344 set_bit(screengrid_layer[0],q,0);
3477 5965344 set_bit(screengrid_layer[1],q,0);
3478
3479 5965344 }
3480
3481
2/2
✓ Branch 0 taken 542304 times.
✓ Branch 1 taken 33894 times.
576198 for(dword q = MAXFFCS/8; q > 0; --q)
3482 542304 ffcgrid[q-1] = 0;
3483 33894 }
3484
3485
4/4
✓ Branch 0 taken 61742 times.
✓ Branch 1 taken 210752 times.
✓ Branch 2 taken 29970 times.
✓ Branch 3 taken 31772 times.
272494 if(dir==up && ((x.getInt()&15)==0))
3486 {
3487 29970 check_slash_block(wx,wy);
3488 29970 check_slash_block(wx,wy+8);
3489
3490 //layers
3491 29970 check_slash_block_layer(wx,wy,1);
3492 29970 check_slash_block_layer(wx,wy+8,1);
3493 29970 check_slash_block_layer(wx,wy,1);
3494 29970 check_slash_block_layer(wx,wy+8,1);
3495 //2
3496 29970 check_slash_block_layer(wx,wy,2);
3497 29970 check_slash_block_layer(wx,wy+8,2);
3498 29970 check_slash_block_layer(wx,wy,2);
3499 29970 check_slash_block_layer(wx,wy+8,2);
3500
3501
3502
3503 29970 }
3504
7/8
✓ Branch 0 taken 31772 times.
✓ Branch 1 taken 210752 times.
✓ Branch 2 taken 1933 times.
✓ Branch 3 taken 29839 times.
✓ Branch 4 taken 134 times.
✓ Branch 5 taken 1799 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 134 times.
242524 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3505 {
3506 31638 check_slash_block(wx,wy);
3507 31638 check_slash_block(wx,wy+8);
3508 31638 check_slash_block(wx+8,wy);
3509 31638 check_slash_block(wx+8,wy+8);
3510 ///layer 1
3511 31638 check_slash_block_layer(wx,wy,1);
3512 31638 check_slash_block_layer(wx,wy+8,1);
3513 31638 check_slash_block_layer(wx+8,wy,1);
3514 31638 check_slash_block_layer(wx+8,wy+8,1);
3515 ///layer 2
3516 31638 check_slash_block_layer(wx,wy,2);
3517 31638 check_slash_block_layer(wx,wy+8,2);
3518 31638 check_slash_block_layer(wx+8,wy,2);
3519 31638 check_slash_block_layer(wx+8,wy+8,2);
3520 31638 }
3521
3522
4/4
✓ Branch 0 taken 60095 times.
✓ Branch 1 taken 212399 times.
✓ Branch 2 taken 29274 times.
✓ Branch 3 taken 30821 times.
272494 if(dir==down && ((x.getInt()&15)==0))
3523 {
3524 30821 check_slash_block(wx,wy+wysz-8);
3525 30821 check_slash_block(wx,wy+wysz);
3526
3527 //layer 1
3528 30821 check_slash_block_layer(wx,wy+wysz-8,1);
3529 30821 check_slash_block_layer(wx,wy+wysz,1);
3530 //layer 2
3531 30821 check_slash_block_layer(wx,wy+wysz-8,2);
3532 30821 check_slash_block_layer(wx,wy+wysz,2);
3533 30821 }
3534
7/8
✓ Branch 0 taken 29274 times.
✓ Branch 1 taken 212399 times.
✓ Branch 2 taken 3466 times.
✓ Branch 3 taken 25808 times.
✓ Branch 4 taken 80 times.
✓ Branch 5 taken 3386 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 80 times.
241673 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3535 {
3536 29194 check_slash_block(wx,wy+wysz-8);
3537 29194 check_slash_block(wx,wy+wysz);
3538 29194 check_slash_block(wx+8,wy+wysz-8);
3539 29194 check_slash_block(wx+8,wy+wysz);
3540 //layer 1
3541 29194 check_slash_block_layer(wx,wy+wysz-8,1);
3542 29194 check_slash_block_layer(wx,wy+wysz,1);
3543 29194 check_slash_block_layer(wx+8,wy+wysz-8,1);
3544 29194 check_slash_block_layer(wx+8,wy+wysz,1);
3545 //layer 2
3546 29194 check_slash_block_layer(wx,wy+wysz-8,2);
3547 29194 check_slash_block_layer(wx,wy+wysz,2);
3548 29194 check_slash_block_layer(wx+8,wy+wysz-8,2);
3549 29194 check_slash_block_layer(wx+8,wy+wysz,2);
3550 29194 }
3551
3552
2/2
✓ Branch 0 taken 198494 times.
✓ Branch 1 taken 74000 times.
272494 if(dir==left)
3553 {
3554 74000 check_slash_block(wx,wy+8);
3555 74000 check_slash_block(wx+8,wy+8);
3556 //layer 1
3557 74000 check_slash_block_layer(wx,wy+8,1);
3558 74000 check_slash_block_layer(wx+8,wy+8,1);
3559 //layer 2
3560 74000 check_slash_block_layer(wx,wy+8,2);
3561 74000 check_slash_block_layer(wx+8,wy+8,2);
3562 74000 }
3563
3564
2/2
✓ Branch 0 taken 195837 times.
✓ Branch 1 taken 76657 times.
272494 if(dir==right)
3565 {
3566 76657 check_slash_block(wx+wxsz,wy+8);
3567 76657 check_slash_block(wx+wxsz-8,wy+8);
3568 //layer 1
3569 76657 check_slash_block_layer(wx+wxsz,wy+8,1);
3570 76657 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3571 //layer 2
3572 76657 check_slash_block_layer(wx+wxsz,wy+8,2);
3573 76657 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3574 76657 }
3575 272494 }
3576
2/2
✓ Branch 0 taken 10709 times.
✓ Branch 1 taken 1520 times.
12229 else if(attack==wWand)
3577 {
3578
1/2
✓ Branch 0 taken 10709 times.
✗ Branch 1 not taken.
10709 if(attackclk == 5)
3579 {
3580 for(int32_t q=0; q<176; q++)
3581 {
3582 set_bit(screengrid,q,0);
3583 set_bit(screengrid_layer[0],q,0);
3584 set_bit(screengrid_layer[1],q,0);
3585 }
3586
3587 for(dword q = MAXFFCS/8; q > 0; --q)
3588 ffcgrid[q-1] = 0;
3589 }
3590
3591 // cutable blocks
3592
4/4
✓ Branch 0 taken 1641 times.
✓ Branch 1 taken 9068 times.
✓ Branch 2 taken 918 times.
✓ Branch 3 taken 723 times.
10709 if(dir==up && (x.getInt()&15)==0)
3593 {
3594 723 check_wand_block(wx,wy);
3595 723 check_wand_block(wx,wy+8);
3596 723 }
3597
5/8
✓ Branch 0 taken 918 times.
✓ Branch 1 taken 9068 times.
✓ Branch 2 taken 630 times.
✓ Branch 3 taken 288 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 630 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9986 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3598 {
3599 918 check_wand_block(wx,wy);
3600 918 check_wand_block(wx,wy+8);
3601 918 check_wand_block(wx+8,wy);
3602 918 check_wand_block(wx+8,wy+8);
3603 918 }
3604
3605
4/4
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 9305 times.
✓ Branch 2 taken 654 times.
✓ Branch 3 taken 750 times.
10709 if(dir==down && (x.getInt()&15)==0)
3606 {
3607 750 check_wand_block(wx,wy+wysz-8);
3608 750 check_wand_block(wx,wy+wysz);
3609 750 }
3610
5/8
✓ Branch 0 taken 654 times.
✓ Branch 1 taken 9305 times.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 519 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9959 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3611 {
3612 654 check_wand_block(wx,wy+wysz-8);
3613 654 check_wand_block(wx,wy+wysz);
3614 654 check_wand_block(wx+8,wy+wysz-8);
3615 654 check_wand_block(wx+8,wy+wysz);
3616 654 }
3617
3618
2/2
✓ Branch 0 taken 6164 times.
✓ Branch 1 taken 4545 times.
10709 if(dir==left)
3619 {
3620 4545 check_wand_block(wx,y+8);
3621 4545 check_wand_block(wx+8,y+8);
3622 4545 }
3623
3624
2/2
✓ Branch 0 taken 7590 times.
✓ Branch 1 taken 3119 times.
10709 if(dir==right)
3625 {
3626 3119 check_wand_block(wx+wxsz,y+8);
3627 3119 check_wand_block(wx+wxsz-8,y+8);
3628 3119 }
3629 10709 }
3630
4/8
✓ Branch 0 taken 1520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1425 times.
✓ Branch 3 taken 95 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1425 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1520 else if((attack==wHammer) && ((attackclk==15) || ( spins>0 && attackclk >=15 )))
3631 {
3632 // poundable blocks
3633
2/2
✓ Branch 0 taken 16720 times.
✓ Branch 1 taken 95 times.
16815 for(int32_t q=0; q<176; q++)
3634 {
3635 16720 set_bit(screengrid,q,0);
3636 16720 set_bit(screengrid_layer[0],q,0);
3637 16720 set_bit(screengrid_layer[1],q,0);
3638 16720 }
3639
3640
2/2
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 95 times.
1615 for(dword q = MAXFFCS/8; q > 0; --q)
3641 1520 ffcgrid[q-1] = 0;
3642
3643
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 23 times.
95 if(dir==up && (x.getInt()&15)==0)
3644 {
3645 23 check_pound_block(wx,wy);
3646 23 check_pound_block(wx,wy+8);
3647 23 }
3648
3/8
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
72 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3649 {
3650 4 check_pound_block(wx,wy);
3651 4 check_pound_block(wx,wy+8);
3652 4 check_pound_block(wx+8,wy);
3653 4 check_pound_block(wx+8,wy+8);
3654 4 }
3655
3656
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 15 times.
95 if(dir==down && (x.getInt()&15)==0)
3657 {
3658 15 check_pound_block(wx,wy+wysz-8);
3659 15 check_pound_block(wx,wy+wysz);
3660 15 }
3661
5/8
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
80 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3662 {
3663 3 check_pound_block(wx,wy+wysz-8);
3664 3 check_pound_block(wx,wy+wysz);
3665 3 check_pound_block(wx+8,wy+wysz-8);
3666 3 check_pound_block(wx+8,wy+wysz);
3667 3 }
3668
3669
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 6 times.
95 if(dir==left)
3670 {
3671 6 check_pound_block(wx,y+8);
3672 6 check_pound_block(wx+8,y+8);
3673 6 }
3674
3675
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 if(dir==right)
3676 {
3677 44 check_pound_block(wx+wxsz,y+8);
3678 44 check_pound_block(wx+wxsz-8,y+8);
3679 44 }
3680 95 }
3681 else
3682 {
3683 1425 return false;
3684 }
3685
3686 283298 return true;
3687 5152190 }
3688
3689 1452328 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
3690 {
3691
2/2
✓ Branch 0 taken 1384 times.
✓ Branch 1 taken 1450944 times.
1452328 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
3692 {
3693 //zprint("bit off\n");
3694 1450944 return;
3695 }
3696 //keep things inside the screen boundaries
3697 1384 bx=vbound(bx, 0, 255);
3698 1384 by=vbound(by, 0, 176);
3699 1384 int32_t fx=vbound(bx, 0, 255);
3700 1384 int32_t fy=vbound(by, 0, 176);
3701 //first things first
3702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1384 times.
1384 if(attack!=wSword)
3703 return;
3704
3705
3/6
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1384 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 140 times.
1524 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3706
3/4
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 1244 times.
1384 || (attackclk>SWORDTAPFRAME && tapping))
3707 return;
3708
3709 //find out which combo row/column the coordinates are in
3710 1384 bx &= 0xF0;
3711 1384 by &= 0xF0;
3712
3713
3714 1384 int32_t flag = MAPFLAGL(layer,bx,by);
3715 1384 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
3716 1384 int32_t cid = MAPCOMBOL(layer,bx,by);
3717 1384 int32_t type = combobuf[cid].type;
3718
1/2
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
1384 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3719 type = cNONE;
3720 //zprint("cid is: %d\n", cid);
3721 //zprint("type is: %d\n", type);
3722 1384 int32_t i = (bx>>4) + by;
3723
3724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1384 times.
1384 if(i > 175)
3725 return;
3726
3727 1384 bool ignorescreen=false;
3728
3729
2/4
✓ Branch 0 taken 1384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1384 times.
✗ Branch 3 not taken.
1384 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
3730 1384 return;
3731
3732 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3733
3734 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
3735 if(isCuttableNextType(type))
3736 {
3737 FFCore.tempScreens[layer]->data[i]++;
3738 }
3739 else
3740 {
3741 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
3742 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
3743 FFCore.tempScreens[layer]->sflag[i] = 0;
3744 }
3745 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3746 {
3747 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3748 sfx(tmpscr->secretsfx);
3749 }
3750 else if(isCuttableItemType(type))
3751 {
3752 int32_t it = -1;
3753 int32_t thedropset = -1;
3754
3755 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
3756 if ( (combobuf[cid].usrflags&cflag2) )
3757 {
3758 if(combobuf[cid].usrflags&cflag11)
3759 it = combobuf[cid].attribytes[1];
3760 else
3761 {
3762 it = select_dropitem(combobuf[cid].attribytes[1]);
3763 thedropset = combobuf[cid].attribytes[1];
3764 }
3765 }
3766 else
3767 {
3768 it = select_dropitem(12);
3769 thedropset = 12;
3770 }
3771 if(it!=-1)
3772 {
3773 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
3774 itm->from_dropset = thedropset;
3775 items.add(itm);
3776 }
3777 }
3778
3779 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
3780
3781 if(get_bit(quest_rules,qr_MORESOUNDS))
3782 {
3783 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
3784 {
3785 if (combobuf[cid].usrflags&cflag3)
3786 {
3787 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3788 }
3789 }
3790 else
3791 {
3792 if (combobuf[cid].usrflags&cflag3)
3793 {
3794 sfx(combobuf[cid].attribytes[2],int32_t(bx));
3795 }
3796 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
3797 }
3798 }
3799
3800 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
3801 if(decotype > 3) decotype = 0;
3802 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
3803 switch(decotype)
3804 {
3805 case -2: break; //nothing
3806 case -1:
3807 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
3808 break;
3809 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
3810 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
3811 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
3812 }
3813 1452328 }
3814
3815 666224 void HeroClass::check_slash_block(int32_t bx, int32_t by)
3816 {
3817 //keep things inside the screen boundaries
3818 666224 bx=vbound(bx, 0, 255);
3819 666224 by=vbound(by, 0, 176);
3820 666224 int32_t fx=vbound(bx, 0, 255);
3821 666224 int32_t fy=vbound(by, 0, 176);
3822 //first things first
3823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 666224 times.
666224 if(attack!=wSword)
3824 return;
3825
3826
4/6
✓ Branch 0 taken 666224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 666224 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 79730 times.
746206 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
3827
4/4
✓ Branch 0 taken 662362 times.
✓ Branch 1 taken 3862 times.
✓ Branch 2 taken 79982 times.
✓ Branch 3 taken 582380 times.
666224 || (attackclk>SWORDTAPFRAME && tapping))
3828 4114 return;
3829
3830 //find out which combo row/column the coordinates are in
3831 662110 bx &= 0xF0;
3832 662110 by &= 0xF0;
3833
3834 662110 int32_t type = COMBOTYPE(bx,by);
3835 662110 int32_t type2 = FFCOMBOTYPE(fx,fy);
3836 662110 int32_t flag = MAPFLAG(bx,by);
3837 662110 int32_t flag2 = MAPCOMBOFLAG(bx,by);
3838 662110 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
3839 662110 int32_t cid = MAPCOMBO(bx,by);
3840 662110 int32_t i = (bx>>4) + by;
3841
3842
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 662089 times.
662110 if(i > 175)
3843 21 return;
3844
3845 662089 bool ignorescreen=false;
3846 662089 bool ignoreffc=false;
3847
3848
2/2
✓ Branch 0 taken 8211 times.
✓ Branch 1 taken 653878 times.
662089 if(get_bit(screengrid, i) != 0)
3849 {
3850 8211 ignorescreen = true;
3851 8211 }
3852
2/2
✓ Branch 0 taken 653873 times.
✓ Branch 1 taken 5 times.
653878 else if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
3853 5 ignorescreen = true;
3854
3855 662089 int32_t current_ffcombo = getFFCAt(fx,fy);
3856
3857
3858
3/4
✓ Branch 0 taken 3709 times.
✓ Branch 1 taken 658380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3709 times.
662089 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
3859 {
3860 658380 ignoreffc = true;
3861 658380 }
3862
2/2
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 19 times.
3709 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
3863 19 ignoreffc = true;
3864
3865
3/4
✓ Branch 0 taken 659556 times.
✓ Branch 1 taken 2533 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 659515 times.
1321604 if(!isCuttableType(type) &&
3866
6/6
✓ Branch 0 taken 1163 times.
✓ Branch 1 taken 658393 times.
✓ Branch 2 taken 659515 times.
✓ Branch 3 taken 41 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 659470 times.
659556 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
3867 {
3868 659515 ignorescreen = true;
3869 659515 }
3870
3871
3/4
✓ Branch 0 taken 662070 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 662070 times.
1324159 if(!isCuttableType(type2) &&
3872
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662070 times.
662070 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
3873 {
3874 662070 ignoreffc = true;
3875 662070 }
3876
3877 662089 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
3878
3879
3/4
✓ Branch 0 taken 32952 times.
✓ Branch 1 taken 629137 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32952 times.
662089 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
3880 662089 byte skipsecrets = 0;
3881
3882
2/2
✓ Branch 0 taken 659579 times.
✓ Branch 1 taken 2510 times.
662089 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
3883 {
3884
2/2
✓ Branch 0 taken 2466 times.
✓ Branch 1 taken 44 times.
2510 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
3885 {
3886 2466 skipsecrets = 0;
3887 2466 }
3888 44 else skipsecrets = 1; ;
3889 2510 }
3890
3891
6/6
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 661063 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 987 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 51 times.
662089 if(!ignorescreen && (!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
3892 {
3893
3/6
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1038 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
3894 {
3895 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3896 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3897 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3898 }
3899
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1034 times.
1038 else if(flag == mfARMOS_SECRET)
3900 {
3901 4 s->data[i] = s->secretcombo[sSTAIRS];
3902 4 s->cset[i] = s->secretcset[sSTAIRS];
3903 4 s->sflag[i] = s->secretflag[sSTAIRS];
3904 4 sfx(tmpscr->secretsfx);
3905 4 }
3906
4/4
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 987 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 981 times.
1034 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
3907 {
3908
4/4
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 103 times.
✓ Branch 3 taken 41 times.
156 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3909 {
3910 103 findentrance(bx,by,mfSWORD+i2,true);
3911 103 }
3912
3913 41 findentrance(bx,by,mfSTRIKE,true);
3914 41 }
3915
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
981 else if(((flag2 >= 16)&&(flag2 <= 31)))
3916 {
3917 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
3918 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
3919 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
3920 }
3921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
981 else if(flag2 == mfARMOS_SECRET)
3922 {
3923 s->data[i] = s->secretcombo[sSTAIRS];
3924 s->cset[i] = s->secretcset[sSTAIRS];
3925 s->sflag[i] = s->secretflag[sSTAIRS];
3926 sfx(tmpscr->secretsfx);
3927 }
3928
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 981 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 981 times.
981 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
3929 {
3930 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3931 {
3932 findentrance(bx,by,mfSWORD+i2,true);
3933 }
3934
3935 findentrance(bx,by,mfSTRIKE,true);
3936 }
3937 else
3938 {
3939
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 21 times.
981 if(isCuttableNextType(type))
3940 {
3941 960 s->data[i]++;
3942 960 }
3943 else
3944 {
3945 21 s->data[i] = s->undercombo;
3946 21 s->cset[i] = s->undercset;
3947 21 s->sflag[i] = 0;
3948 }
3949
3950 //pausenow=true;
3951 }
3952 1026 }
3953
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 661075 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
661075 else if(!ignorescreen && skipsecrets)
3954 {
3955 if(isCuttableNextType(type))
3956 {
3957 s->data[i]++;
3958 }
3959 else
3960 {
3961 s->data[i] = s->undercombo;
3962 s->cset[i] = s->undercset;
3963 s->sflag[i] = 0;
3964 }
3965 }
3966
3967
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 662101 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 662101 times.
662101 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
3968 {
3969 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
3970 {
3971 findentrance(bx,by,mfSWORD+i2,true);
3972 }
3973
3974 findentrance(fx,fy,mfSTRIKE,true);
3975 }
3976
1/2
✓ Branch 0 taken 662101 times.
✗ Branch 1 not taken.
662101 else if(!ignoreffc)
3977 {
3978 if(isCuttableNextType(type2))
3979 {
3980 s->ffcs[current_ffcombo].incData(1);
3981 }
3982 else
3983 {
3984 s->ffcs[current_ffcombo].setData(s->undercombo);
3985 s->ffcs[current_ffcombo].cset = s->undercset;
3986 }
3987 }
3988
3989
2/2
✓ Branch 0 taken 661075 times.
✓ Branch 1 taken 1026 times.
662101 if(!ignorescreen)
3990 {
3991
4/4
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 955 times.
1026 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
3992
3993
5/8
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6 times.
1026 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
3994 {
3995
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
3996 6 sfx(tmpscr->secretsfx);
3997 6 }
3998
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 977 times.
1020 else if(isCuttableItemType(type))
3999 {
4000 977 int32_t it = -1;
4001 977 int32_t thedropset = -1;
4002
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 955 times.
977 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4003 {
4004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if ( combobuf[cid].usrflags&cflag11 )
4005 {
4006 it = combobuf[cid].attribytes[1];
4007 }
4008 else
4009 {
4010 22 it = select_dropitem(combobuf[cid].attribytes[1]);
4011 22 thedropset = combobuf[cid].attribytes[1];
4012 }
4013 22 }
4014 else
4015 {
4016 955 it = select_dropitem(12);
4017 955 thedropset = 12;
4018 }
4019
4020
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 238 times.
977 if(it!=-1)
4021 {
4022
4/8
✓ Branch 0 taken 238 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 238 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 238 times.
✗ Branch 7 not taken.
238 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4023 238 itm->from_dropset = thedropset;
4024 238 items.add(itm);
4025 238 }
4026 977 }
4027
4028 1026 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4029
4030
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 193 times.
1026 if(get_bit(quest_rules,qr_MORESOUNDS))
4031 {
4032
6/6
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 44 times.
193 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4033 {
4034
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 22 times.
44 if (combobuf[cid].usrflags&cflag3)
4035 {
4036 22 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4037 22 }
4038 44 }
4039 else
4040 {
4041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (combobuf[cid].usrflags&cflag3)
4042 {
4043 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4044 }
4045 149 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4046 }
4047 193 }
4048
4049
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 906 times.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
1026 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4050
1/2
✓ Branch 0 taken 1026 times.
✗ Branch 1 not taken.
1026 if(decotype > 3) decotype = 0;
4051
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 906 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 606 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 606 times.
✓ Branch 6 taken 531 times.
✓ Branch 7 taken 75 times.
1026 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4052
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399 times.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 531 times.
1026 switch(decotype)
4053 {
4054 75 case -2: break; //nothing
4055 case -1:
4056 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4057 break;
4058
3/6
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 399 times.
✗ Branch 5 not taken.
399 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4059
3/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
21 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4060
3/6
✓ Branch 0 taken 531 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 531 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 531 times.
✗ Branch 5 not taken.
531 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4061 }
4062 1026 }
4063
4064
1/2
✓ Branch 0 taken 662101 times.
✗ Branch 1 not taken.
662101 if(!ignoreffc)
4065 {
4066 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4067
4068 if(isCuttableItemType(type2))
4069 {
4070 int32_t it=-1;
4071 int32_t thedropset=-1;
4072 if ( (combobuf[cid].usrflags&cflag2) )
4073 {
4074 if(combobuf[cid].usrflags&cflag11)
4075 it = combobuf[cid].attribytes[1];
4076 else
4077 {
4078 it = select_dropitem(combobuf[cid].attribytes[1]);
4079 thedropset = combobuf[cid].attribytes[1];
4080 }
4081 }
4082 else
4083 {
4084 int32_t r=zc_oldrand()%100;
4085
4086 if(r<15)
4087 {
4088 it=iHeart; // 15%
4089 }
4090 else if(r<35)
4091 {
4092 it=iRupy; // 20%
4093 }
4094 }
4095
4096 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4097 {
4098 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4099 itm->from_dropset = thedropset;
4100 items.add(itm);
4101 }
4102 }
4103
4104 if(get_bit(quest_rules,qr_MORESOUNDS))
4105 {
4106 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4107 {
4108 if (combobuf[cid].usrflags&cflag3)
4109 {
4110 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4111 }
4112 }
4113 else
4114 {
4115 if (combobuf[cid].usrflags&cflag3)
4116 {
4117 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4118 }
4119 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4120 }
4121 }
4122
4123 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4124 if(decotype > 3) decotype = 0;
4125 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4126 switch(decotype)
4127 {
4128 case -2: break; //nothing
4129 case -1:
4130 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4131 break;
4132 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4133 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4134 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4135 }
4136 }
4137 666236 }
4138
4139 11608918 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4140 {
4141 /*
4142 int32_t par_item = w->parentitem;
4143 al_trace("check_wpn_triggers(weapon *w): par_item is: %d\n", par_item);
4144 int32_t usewpn = -1;
4145 if ( par_item > -1 )
4146 {
4147 usewpn = itemsbuf[par_item].useweapon;
4148 }
4149 else if ( par_item == -1 && w->ScriptGenerated )
4150 {
4151 usewpn = w->useweapon;
4152 }
4153 al_trace("check_wpn_triggers(weapon *w): usewpn is: %d\n", usewpn);
4154
4155 */
4156 11608918 bx=vbound(bx, 0, 255);
4157 11608918 by=vbound(by, 0, 176);
4158 11608918 int32_t cid = MAPCOMBO(bx,by);
4159
3/30
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 201168 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 11406502 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 1248 times.
✗ Branch 29 not taken.
11608918 switch(w->useweapon)
4160 {
4161 case wArrow:
4162 findentrance(bx,by,mfARROW,true);
4163 findentrance(bx,by,mfSARROW,true);
4164 findentrance(bx,by,mfGARROW,true);
4165 break;
4166 case wBeam:
4167 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4168 break;
4169 case wHookshot:
4170 findentrance(bx,by,mfHOOKSHOT,true);
4171 break;
4172 case wBrang:
4173 for(int32_t i = 0; i <3; i++) findentrance(bx,by,mfBRANG+i,true);
4174 break;
4175 case wMagic:
4176 findentrance(bx,by,mfWANDMAGIC,true);
4177 break;
4178 case wRefMagic:
4179 findentrance(bx,by,mfWANDMAGIC,true);
4180 break;
4181 case wRefBeam:
4182 for(int32_t i = 0; i <4; i++) findentrance(bx,by,mfSWORDBEAM+i,true);
4183 break;
4184 //reflected magic needs to happen in mirrors:
4185 //
4186 //findentrance(bx,by,mfREFMAGIC,true)
4187 case wRefFireball:
4188 findentrance(bx,by,mfREFFIREBALL,true);
4189 break;
4190 case wBomb:
4191 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4192 break;
4193
4194 case wSBomb:
4195 findentrance(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4196 break;
4197
4198 case wFire:
4199 201168 findentrance(bx,by,mfBCANDLE,true);
4200 201168 findentrance(bx,by,mfRCANDLE,true);
4201 201168 findentrance(bx,by,mfWANDFIRE,true);
4202 /* if we want the weapon to die
4203 if (findentrance(bx,by,mfBCANDLE,true) ) dead = 1;
4204 if (findentrance(bx,by,mfRCANDLE,true) ) dead = 1;
4205 if (findentrance(bx,by,mfWANDFIRE,true)) dead = 1;
4206 */
4207 201168 break;
4208
4209 case wScript1:
4210 break;
4211 case wScript2:
4212 break;
4213 case wScript3:
4214 break;
4215 case wScript4:
4216 break;
4217 case wScript5:
4218 break;
4219 case wScript6:
4220 break;
4221 case wScript7:
4222 break;
4223 case wScript8:
4224 break;
4225 case wScript9:
4226 break;
4227 case wScript10:
4228 break;
4229 case wIce:
4230 break;
4231 case wCByrna:
4232 break;
4233 case wWhistle:
4234 break;
4235 case wSSparkle:
4236 case wFSparkle:
4237 break;
4238 case wWind:
4239 break;
4240 case wBait:
4241 break;
4242 case wFlame:
4243 case wThrown:
4244 case wBombos:
4245 case wEther:
4246 case wQuake:
4247 case wSwordLA:
4248 case wSword180:
4249 case wStomp:
4250 break;
4251 case wSword:
4252 case wWand:
4253 //case wCandle:
4254 case wHSHandle:
4255 case wLitBomb:
4256 case wLitSBomb:
4257 1248 break;
4258 11406502 default: break;
4259
4260 }
4261 11608918 }
4262
4263 23217836 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4264 {
4265
4266
2/2
✓ Branch 0 taken 95766 times.
✓ Branch 1 taken 23122070 times.
23217836 if(!(get_bit(quest_rules,qr_BUSHESONLAYERS1AND2)))
4267 {
4268 //zprint("bit off\n");
4269 23122070 return;
4270 }
4271 //keep things inside the screen boundaries
4272 95766 bx=vbound(bx, 0, 255);
4273 95766 by=vbound(by, 0, 176);
4274 95766 int32_t fx=vbound(bx, 0, 255);
4275 95766 int32_t fy=vbound(by, 0, 176);
4276 //first things first
4277
1/2
✓ Branch 0 taken 95766 times.
✗ Branch 1 not taken.
95766 if(w->useweapon != wSword)
4278 95766 return;
4279
4280 //find out which combo row/column the coordinates are in
4281 bx &= 0xF0;
4282 by &= 0xF0;
4283
4284
4285 int32_t flag = MAPFLAGL(layer,bx,by);
4286 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4287 int32_t cid = MAPCOMBOL(layer,bx,by);
4288 int32_t type = combobuf[cid].type;
4289 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4290 type = cNONE;
4291 //zprint("cid is: %d\n", cid);
4292 //zprint("type is: %d\n", type);
4293 int32_t i = (bx>>4) + by;
4294
4295 if(i > 175)
4296 return;
4297
4298 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4299 {
4300 return;
4301 //ignorescreen = true;
4302 //zprint("ignoring\n");
4303 }
4304
4305 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4306
4307 {
4308 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4309 if(isCuttableNextType(type) || isCuttableNextType(type))
4310 {
4311 FFCore.tempScreens[layer]->data[i]++;
4312 }
4313 else
4314 {
4315 FFCore.tempScreens[layer]->data[i] = tmpscr->undercombo;
4316 FFCore.tempScreens[layer]->cset[i] = tmpscr->undercset;
4317 FFCore.tempScreens[layer]->sflag[i] = 0;
4318 }
4319 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4320 {
4321 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4322 sfx(tmpscr->secretsfx);
4323 }
4324 else if(isCuttableItemType(type))
4325 {
4326 int32_t it = -1;
4327 int32_t thedropset = -1;
4328
4329 if ( (combobuf[cid].usrflags&cflag2) )
4330 {
4331 if(combobuf[cid].usrflags&cflag11)
4332 it = combobuf[cid].attribytes[1];
4333 else
4334 {
4335 it = select_dropitem(combobuf[cid].attribytes[1]);
4336 thedropset = combobuf[cid].attribytes[1];
4337 }
4338 }
4339 else
4340 {
4341 it = select_dropitem(12);
4342 thedropset = 12;
4343 }
4344
4345 if(it!=-1)
4346 {
4347 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4348 itm->from_dropset = thedropset;
4349 items.add(itm);
4350 }
4351 }
4352
4353 putcombo(scrollbuf,(i&15)<<4,i&0xF0,tmpscr->data[i],tmpscr->cset[i]);
4354
4355 if(get_bit(quest_rules,qr_MORESOUNDS))
4356 {
4357 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4358 {
4359 if (combobuf[cid].usrflags&cflag3)
4360 {
4361 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4362 }
4363 }
4364 else
4365 {
4366 if (combobuf[cid].usrflags&cflag3)
4367 {
4368 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4369 }
4370 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4371 }
4372 }
4373
4374 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4375 if(decotype > 3) decotype = 0;
4376 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4377 switch(decotype)
4378 {
4379 case -2: break; //nothing
4380 case -1:
4381 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4382 break;
4383 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4384 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4385 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4386 }
4387
4388 }
4389
4390 23217836 }
4391
4392 11608918 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4393 {
4394 /*
4395 int32_t par_item = w->parentitem;
4396 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4397 int32_t usewpn = -1;
4398 if ( par_item > -1 )
4399 {
4400 usewpn = itemsbuf[par_item].useweapon;
4401 }
4402 else if ( par_item == -1 && w->ScriptGenerated )
4403 {
4404 usewpn = w->useweapon;
4405 }
4406 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4407 */
4408
4409
4410 //keep things inside the screen boundaries
4411 11608918 bx=vbound(bx, 0, 255);
4412 11608918 by=vbound(by, 0, 176);
4413 11608918 int32_t fx=vbound(bx, 0, 255);
4414 11608918 int32_t fy=vbound(by, 0, 176);
4415 11608918 int32_t cid = MAPCOMBO(bx,by);
4416
4417 //find out which combo row/column the coordinates are in
4418 11608918 bx &= 0xF0;
4419 11608918 by &= 0xF0;
4420
4421 11608918 int32_t type = COMBOTYPE(bx,by);
4422 11608918 int32_t type2 = FFCOMBOTYPE(fx,fy);
4423 11608918 int32_t flag = MAPFLAG(bx,by);
4424 11608918 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4425 11608918 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4426
2/2
✓ Branch 0 taken 11608704 times.
✓ Branch 1 taken 214 times.
11608918 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4427 214 type = cNONE;
4428 11608918 byte dontignore = 0;
4429 11608918 byte dontignoreffc = 0;
4430
4431
4/4
✓ Branch 0 taken 175720 times.
✓ Branch 1 taken 11433198 times.
✓ Branch 2 taken 175421 times.
✓ Branch 3 taken 299 times.
11608918 if (isCuttableType(type) && MatchComboTrigger(w, combobuf, cid))
4432 {
4433 299 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4434 299 dontignore = 1;
4435 299 }
4436
4437 /*to-do, ffcs
4438 if (isCuttableType(type2) && MatchComboTrigger(w, combobuf, cid))
4439 {
4440 al_trace("This weapon (%d) can slash the combo: combobuf[%d].\n", w->id, cid);
4441 dontignoreffc = 1;
4442 }*/
4443
4/4
✓ Branch 0 taken 11607670 times.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 11607371 times.
✓ Branch 3 taken 299 times.
11608918 if(w->useweapon != wSword && !dontignore) return;
4444
4445
4446 1547 int32_t i = (bx>>4) + by;
4447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4448
4449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 if(i > 175)
4450 return;
4451
4452 1547 bool ignorescreen=false;
4453 1547 bool ignoreffc=false;
4454
4455
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(get_bit(w->wscreengrid, i) != 0)
4456 {
4457 ignorescreen = true; dontignore = 0;
4458 }
4459
4460 1547 int32_t current_ffcombo = getFFCAt(fx,fy);
4461
4462
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1545 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
1547 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4463 {
4464 1545 ignoreffc = true;
4465 1545 }
4466
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4467 type2 = cNONE;
4468
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
2795 if(!isCuttableType(type) &&
4469
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✓ Branch 2 taken 1248 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1248 times.
1248 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4470 {
4471 1248 ignorescreen = true;
4472 1248 }
4473
4474
2/4
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
3094 if(!isCuttableType(type2) &&
4475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
1547 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4476 {
4477 1547 ignoreffc = true;
4478 1547 }
4479
4480 1547 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4481
4482
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 293 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1248 times.
1547 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? itemsbuf[directWpn].fam_type : current_item(itype_sword);
4483 1547 byte skipsecrets = 0;
4484
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 249 times.
1547 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4485 {
4486
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (get_bit(quest_rules,qr_OLD_SLASHNEXT_SECRETS))
4487 {
4488 249 skipsecrets = 0;
4489 249 }
4490 else skipsecrets = 1;
4491 249 }
4492
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 1248 times.
✓ Branch 4 taken 1248 times.
✓ Branch 5 taken 1547 times.
1547 if((!skipsecrets || !get_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4493 {
4494
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2795 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4495 {
4496 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4497 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4498 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4499 }
4500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag == mfARMOS_SECRET)
4501 {
4502 s->data[i] = s->secretcombo[sSTAIRS];
4503 s->cset[i] = s->secretcset[sSTAIRS];
4504 s->sflag[i] = s->secretflag[sSTAIRS];
4505 sfx(tmpscr->secretsfx);
4506 }
4507
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4508 {
4509 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4510 {
4511 findentrance(bx,by,mfSWORD+i2,true);
4512 }
4513
4514 findentrance(bx,by,mfSTRIKE,true);
4515 }
4516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
299 else if(((flag2 >= 16)&&(flag2 <= 31)))
4517 {
4518 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4519 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4520 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4521 }
4522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(flag2 == mfARMOS_SECRET)
4523 {
4524 s->data[i] = s->secretcombo[sSTAIRS];
4525 s->cset[i] = s->secretcset[sSTAIRS];
4526 s->sflag[i] = s->secretflag[sSTAIRS];
4527 sfx(tmpscr->secretsfx);
4528 }
4529
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
299 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4530 {
4531 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4532 {
4533 findentrance(bx,by,mfSWORD+i2,true);
4534 }
4535
4536 findentrance(bx,by,mfSTRIKE,true);
4537 }
4538 else
4539 {
4540
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 50 times.
299 if(isCuttableNextType(type))
4541 {
4542 249 s->data[i]++;
4543 249 }
4544 else
4545 {
4546 50 s->data[i] = s->undercombo;
4547 50 s->cset[i] = s->undercset;
4548 50 s->sflag[i] = 0;
4549 }
4550
4551 //pausenow=true;
4552 }
4553 299 }
4554
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1248 else if(skipsecrets && (!ignorescreen || dontignore))
4555 {
4556 if(isCuttableNextType(type))
4557 {
4558 s->data[i]++;
4559 }
4560 else
4561 {
4562 s->data[i] = s->undercombo;
4563 s->cset[i] = s->undercset;
4564 s->sflag[i] = 0;
4565 }
4566 }
4567
4568
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1547 times.
1547 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4569 {
4570 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4571 {
4572 findentrance(bx,by,mfSWORD+i2,true);
4573 }
4574
4575 findentrance(fx,fy,mfSTRIKE,true);
4576 }
4577
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 else if(!ignoreffc)
4578 {
4579 if(isCuttableNextType(type2))
4580 {
4581 s->ffcs[current_ffcombo].incData(1);
4582 }
4583 else
4584 {
4585 s->ffcs[current_ffcombo].setData(s->undercombo);
4586 s->ffcs[current_ffcombo].cset = s->undercset;
4587 }
4588 }
4589
4590
3/4
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248 times.
1547 if(!ignorescreen || dontignore)
4591 {
4592
3/4
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 211 times.
299 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4593
4594
2/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 299 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4595 {
4596 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4597 sfx(tmpscr->secretsfx);
4598 }
4599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 else if(isCuttableItemType(type))
4600 {
4601 299 int32_t it = -1;
4602 299 int32_t thedropset = -1;
4603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4604 {
4605 if ( combobuf[cid].usrflags&cflag11 )
4606 {
4607 it = combobuf[cid].attribytes[1];
4608 }
4609 else
4610 {
4611 it = select_dropitem(combobuf[cid].attribytes[1]);
4612 thedropset = combobuf[cid].attribytes[1];
4613 }
4614 }
4615 else
4616 {
4617 299 it = select_dropitem(12);
4618 299 thedropset = 12;
4619 }
4620
4621
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 99 times.
299 if(it!=-1)
4622 {
4623
4/8
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 99 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 99 times.
✗ Branch 7 not taken.
99 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4624 99 itm->from_dropset = thedropset;
4625 99 items.add(itm);
4626 99 }
4627 299 }
4628
4629
4630 299 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4631
4632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if(get_bit(quest_rules,qr_MORESOUNDS))
4633 {
4634
5/6
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 161 times.
✗ Branch 5 not taken.
299 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4635 {
4636 if (combobuf[cid].usrflags&cflag3)
4637 {
4638 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4639 }
4640 }
4641 else
4642 {
4643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if (combobuf[cid].usrflags&cflag3)
4644 {
4645 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4646 }
4647 299 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4648 }
4649 299 }
4650
4651
2/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 299 times.
✗ Branch 3 not taken.
299 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4652
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(decotype > 3) decotype = 0;
4653
1/8
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
299 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4654
2/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
299 switch(decotype)
4655 {
4656 case -2: break; //nothing
4657 case -1:
4658 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4659 break;
4660
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
249 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4661
3/6
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50 times.
✗ Branch 5 not taken.
50 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4662 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4663 }
4664 299 }
4665
4666
1/2
✓ Branch 0 taken 1547 times.
✗ Branch 1 not taken.
1547 if(!ignoreffc)
4667 {
4668 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
4669
4670 if(isCuttableItemType(type2))
4671 {
4672 int32_t it=-1;
4673 int32_t thedropset=-1;
4674 if ( (combobuf[cid].usrflags&cflag2) )
4675 {
4676 if(combobuf[cid].usrflags&cflag11)
4677 it = combobuf[cid].attribytes[1];
4678 else
4679 {
4680 it = select_dropitem(combobuf[cid].attribytes[1]);
4681 thedropset = combobuf[cid].attribytes[1];
4682 }
4683 }
4684 else
4685 {
4686 int32_t r=zc_oldrand()%100;
4687
4688 if(r<15)
4689 {
4690 it=iHeart; // 15%
4691 }
4692 else if(r<35)
4693 {
4694 it=iRupy; // 20%
4695 }
4696 }
4697
4698 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
4699 {
4700 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4701 itm->from_dropset = thedropset;
4702 items.add(itm);
4703 }
4704 }
4705
4706 if(get_bit(quest_rules,qr_MORESOUNDS))
4707 {
4708 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4709 {
4710 if (combobuf[cid].usrflags&cflag3)
4711 {
4712 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4713 }
4714 }
4715 else
4716 {
4717 if (combobuf[cid].usrflags&cflag3)
4718 {
4719 sfx(combobuf[cid].attribytes[2],int32_t(bx));
4720 }
4721 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
4722 }
4723 }
4724
4725 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4726 if(decotype > 3) decotype = 0;
4727 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4728 switch(decotype)
4729 {
4730 case -2: break; //nothing
4731 case -1:
4732 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
4733 break;
4734 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4735 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4736 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4737 }
4738 }
4739 11608918 }
4740
4741 11608918 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
4742 {
4743 /*
4744 int32_t par_item = w->parentitem;
4745 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
4746 int32_t usewpn = -1;
4747 if ( par_item > -1 )
4748 {
4749 usewpn = itemsbuf[par_item].useweapon;
4750 }
4751 else if ( par_item == -1 && w->ScriptGenerated )
4752 {
4753 usewpn = w->useweapon;
4754 }
4755 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
4756 */
4757
4758 11608918 byte dontignore = 0;
4759 11608918 byte dontignoreffc = 0;
4760
4761
4762
4763
4764
4765 //keep things inside the screen boundaries
4766 11608918 bx=vbound(bx, 0, 255);
4767 11608918 by=vbound(by, 0, 176);
4768 11608918 int32_t fx=vbound(bx, 0, 255);
4769 11608918 int32_t fy=vbound(by, 0, 176);
4770 11608918 int32_t cid = MAPCOMBO(bx,by);
4771
4772 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
4773
3/4
✓ Branch 0 taken 11608918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✓ Branch 3 taken 11608259 times.
11608918 if(w->useweapon != wWand && !MatchComboTrigger (w, combobuf, cid)) return;
4774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 659 times.
659 if ( MatchComboTrigger (w, combobuf, cid) ) dontignore = 1;
4775
4776 //first things first
4777
2/4
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 659 times.
659 if(z>8||fakez>8) return;
4778
4779 //find out which combo row/column the coordinates are in
4780 659 bx &= 0xF0;
4781 659 by &= 0xF0;
4782
4783 659 int32_t flag = MAPFLAG(bx,by);
4784 659 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4785 659 int32_t flag3=0;
4786 659 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
4787 659 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
4788 659 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
4789 659 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
4790
4791
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
4792 flag3=mfWAND;
4793
4794
4/8
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 659 times.
659 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
4795 flag3=mfSTRIKE;
4796
4797 659 int32_t i = (bx>>4) + by;
4798
4799
6/12
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 659 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 659 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 659 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 659 times.
659 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
4800 659 return;
4801
4802 if(i > 175)
4803 return;
4804
4805 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4806
4807 //findentrance(bx,by,mfWAND,true);
4808 //findentrance(bx,by,mfSTRIKE,true);
4809 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
4810 {
4811 if(flag3==mfWAND||flag3==mfSTRIKE)
4812 {
4813 findentrance(fx,fy,mfWAND,true);
4814 findentrance(fx,fy,mfSTRIKE,true);
4815 }
4816 }
4817
4818 if(dontignore) { findentrance(bx,by,mfWAND,true); }
4819
4820 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4821 11608918 }
4822
4823 11608918 void HeroClass::check_pound_block2(int32_t bx, int32_t by, weapon *w)
4824 {
4825 /*
4826 int32_t par_item = w->parentitem;
4827 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
4828 int32_t usewpn = -1;
4829 if ( par_item > -1 )
4830 {
4831 usewpn = itemsbuf[par_item].useweapon;
4832 }
4833 else if ( par_item == -1 && w->ScriptGenerated )
4834 {
4835 usewpn = w->useweapon;
4836 }
4837 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
4838 */
4839 //keep things inside the screen boundaries
4840 11608918 bx=vbound(bx, 0, 255);
4841 11608918 by=vbound(by, 0, 176);
4842 11608918 int32_t fx=vbound(bx, 0, 255);
4843 11608918 int32_t fy=vbound(by, 0, 176);
4844 11608918 int32_t cid = MAPCOMBO(bx,by);
4845 11608918 byte dontignore = MatchComboTrigger (w, combobuf, cid);
4846
3/4
✓ Branch 0 taken 11608918 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 659 times.
✓ Branch 3 taken 11608259 times.
11608918 if(w->useweapon != wHammer && !dontignore ) return;
4847
4848
4849
4850
4851 //first things first
4852
2/4
✓ Branch 0 taken 659 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 659 times.
659 if(z>8||fakez>8) return;
4853
4854 //find out which combo row/column the coordinates are in
4855 659 bx &= 0xF0;
4856 659 by &= 0xF0;
4857
4858 659 int32_t type = COMBOTYPE(bx,by);
4859 659 int32_t type2 = FFCOMBOTYPE(fx,fy);
4860 659 int32_t flag = MAPFLAG(bx,by);
4861 659 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4862 659 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4863 659 int32_t i = (bx>>4) + by;
4864
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 514 times.
659 if (get_bit(w->wscreengrid,(((bx>>4) + by))) ) return;
4865
4866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 514 times.
514 if(i > 175)
4867 return;
4868
4869 514 bool ignorescreen=false;
4870 514 bool ignoreffc=false;
4871 514 bool pound=false;
4872
4873
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 47 times.
514 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
4874 47 type = cNONE;
4875
5/10
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 514 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 514 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 514 times.
514 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
4876 514 ignorescreen = true; // Affect only FFCs
4877
4878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 514 times.
514 if(get_bit(w->wscreengrid, i) != 0)
4879 {
4880 ignorescreen = true; dontignore = 0;
4881 }
4882
4883 514 int32_t current_ffcombo = getFFCAt(fx,fy);
4884
4885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 514 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
514 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
4886 514 ignoreffc = true;
4887 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
4888 type2 = cNONE;
4889
3/6
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 514 times.
514 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
4890 514 ignoreffc = true;
4891
4892
2/4
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 514 times.
514 if(ignorescreen && ignoreffc) // Nothing to do.
4893 514 return;
4894
4895 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
4896
4897 if(!ignorescreen || dontignore)
4898 {
4899 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
4900 {
4901 findentrance(bx,by,mfHAMMER,true);
4902 findentrance(bx,by,mfSTRIKE,true);
4903 }
4904 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
4905 {
4906 findentrance(bx,by,mfHAMMER,true);
4907 findentrance(bx,by,mfSTRIKE,true);
4908 }
4909 else if((flag >= 16)&&(flag <= 31))
4910 {
4911 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4912 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4913 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4914 }
4915 else if(flag == mfARMOS_SECRET)
4916 {
4917 s->data[i] = s->secretcombo[sSTAIRS];
4918 s->cset[i] = s->secretcset[sSTAIRS];
4919 s->sflag[i] = s->secretflag[sSTAIRS];
4920 sfx(tmpscr->secretsfx);
4921 }
4922 else if((flag2 >= 16)&&(flag2 <= 31))
4923 {
4924 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4925 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4926 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4927 }
4928 else if(flag2 == mfARMOS_SECRET)
4929 {
4930 s->data[i] = s->secretcombo[sSTAIRS];
4931 s->cset[i] = s->secretcset[sSTAIRS];
4932 s->sflag[i] = s->secretflag[sSTAIRS];
4933 sfx(tmpscr->secretsfx);
4934 }
4935 else pound = true;
4936 }
4937
4938 if(!ignoreffc)
4939 {
4940 if(flag3==mfHAMMER||flag3==mfSTRIKE)
4941 {
4942 findentrance(fx,fy,mfHAMMER,true);
4943 findentrance(fx,fy,mfSTRIKE,true);
4944 }
4945 else
4946 {
4947 s->ffcs[current_ffcombo].incData(1);
4948 }
4949 }
4950
4951 if(!ignorescreen || dontignore)
4952 {
4953 if(pound)
4954 s->data[i]+=1;
4955
4956 set_bit(w->wscreengrid,i,1);
4957
4958 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
4959 {
4960 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4961 sfx(tmpscr->secretsfx);
4962 }
4963
4964 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4965 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4966
4967 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
4968 }
4969
4970 if(!ignoreffc)
4971 {
4972 set_bit(ffcgrid,current_ffcombo,1);
4973
4974 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
4975 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
4976 }
4977
4978 return;
4979 11608918 }
4980
4981 void HeroClass::check_slash_block(weapon *w)
4982 {
4983 //first things
4984
4985 int32_t par_item = w->parentitem;
4986 al_trace("check_slash_block(weapon *w): par_item is: %d\n", par_item);
4987 int32_t usewpn = -1;
4988 if ( par_item > -1 )
4989 {
4990 usewpn = itemsbuf[par_item].useweapon;
4991 }
4992 else if ( par_item == -1 && w->ScriptGenerated )
4993 {
4994 usewpn = w->useweapon;
4995 }
4996 al_trace("check_slash_block(weapon *w): usewpn is: %d\n", usewpn);
4997 if(usewpn != wSword) return;
4998
4999
5000 int32_t bx = 0, by = 0;
5001 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5002 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5003 al_trace("check_slash_block(weapon *w): bx is: %d\n", bx);
5004 al_trace("check_slash_block(weapon *w): by is: %d\n", by);
5005 //keep things inside the screen boundaries
5006 bx=vbound(bx, 0, 255);
5007 by=vbound(by, 0, 176);
5008 int32_t fx=vbound(bx, 0, 255);
5009 int32_t fy=vbound(by, 0, 176);
5010
5011 int32_t cid = MAPCOMBO(bx,by);
5012
5013 //find out which combo row/column the coordinates are in
5014 bx &= 0xF0;
5015 by &= 0xF0;
5016
5017 int32_t type = COMBOTYPE(bx,by);
5018 int32_t type2 = FFCOMBOTYPE(fx,fy);
5019 int32_t flag = MAPFLAG(bx,by);
5020 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5021 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5022 int32_t i = (bx>>4) + by;
5023
5024 if(i > 175)
5025 {
5026 al_trace("check_slash_block(weapon *w): %s\n", "i > 175");
5027 return;
5028 }
5029
5030 if(combobuf[cid].triggerflags[0] & combotriggerONLYGENTRIG)
5031 type = cNONE;
5032 bool ignorescreen=false;
5033 bool ignoreffc=false;
5034
5035 if(get_bit(screengrid, i) != 0)
5036 {
5037 ignorescreen = true;
5038 }
5039
5040 int32_t current_ffcombo = getFFCAt(fx,fy);
5041
5042 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5043 {
5044 ignoreffc = true;
5045 }
5046 else if(combobuf[tmpscr->ffcs[current_ffcombo].getData()].triggerflags[0] & combotriggerONLYGENTRIG)
5047 type2 = cNONE;
5048 if(!isCuttableType(type) &&
5049 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5050 {
5051 ignorescreen = true;
5052 }
5053
5054 if(!isCuttableType(type2) &&
5055 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5056 {
5057 ignoreffc = true;
5058 }
5059
5060 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5061
5062 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].fam_type : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5063
5064 if(!ignorescreen)
5065 {
5066 if((flag >= 16)&&(flag <= 31))
5067 {
5068 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5069 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5070 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5071 }
5072 else if(flag == mfARMOS_SECRET)
5073 {
5074 s->data[i] = s->secretcombo[sSTAIRS];
5075 s->cset[i] = s->secretcset[sSTAIRS];
5076 s->sflag[i] = s->secretflag[sSTAIRS];
5077 sfx(tmpscr->secretsfx);
5078 }
5079 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5080 {
5081 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5082 {
5083 findentrance(bx,by,mfSWORD+i2,true);
5084 }
5085
5086 findentrance(bx,by,mfSTRIKE,true);
5087 }
5088 else if(((flag2 >= 16)&&(flag2 <= 31)))
5089 {
5090 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5091 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5092 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5093 }
5094 else if(flag2 == mfARMOS_SECRET)
5095 {
5096 s->data[i] = s->secretcombo[sSTAIRS];
5097 s->cset[i] = s->secretcset[sSTAIRS];
5098 s->sflag[i] = s->secretflag[sSTAIRS];
5099 sfx(tmpscr->secretsfx);
5100 }
5101 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5102 {
5103 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5104 {
5105 findentrance(bx,by,mfSWORD+i2,true);
5106 }
5107
5108 findentrance(bx,by,mfSTRIKE,true);
5109 }
5110 else
5111 {
5112 if(isCuttableNextType(type))
5113 {
5114 s->data[i]++;
5115 }
5116 else
5117 {
5118 s->data[i] = s->undercombo;
5119 s->cset[i] = s->undercset;
5120 s->sflag[i] = 0;
5121 }
5122
5123 //pausenow=true;
5124 }
5125 }
5126
5127 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5128 {
5129 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5130 {
5131 findentrance(bx,by,mfSWORD+i2,true);
5132 }
5133
5134 findentrance(fx,fy,mfSTRIKE,true);
5135 }
5136 else if(!ignoreffc)
5137 {
5138 if(isCuttableNextType(type2))
5139 {
5140 s->ffcs[current_ffcombo].incData(1);
5141 }
5142 else
5143 {
5144 s->ffcs[current_ffcombo].setData(s->undercombo);
5145 s->ffcs[current_ffcombo].cset = s->undercset;
5146 }
5147 }
5148
5149 if(!ignorescreen)
5150 {
5151 if(!isTouchyType(type) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5152
5153 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5154 {
5155 items.add(new item((zfix)bx, (zfix)by,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5156 sfx(tmpscr->secretsfx);
5157 }
5158 else if(isCuttableItemType(type))
5159 {
5160 int32_t it = -1;
5161 int32_t thedropset = -1;
5162 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5163 {
5164 if ( combobuf[cid].usrflags&cflag11 )
5165 {
5166 it = combobuf[cid].attribytes[1];
5167 }
5168 else
5169 {
5170 it = select_dropitem(combobuf[cid].attribytes[1]);
5171 thedropset = combobuf[cid].attribytes[1];
5172 }
5173 }
5174 else
5175 {
5176 it = select_dropitem(12);
5177 thedropset = 12;
5178 }
5179
5180 if(it!=-1)
5181 {
5182 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5183 itm->from_dropset = thedropset;
5184 items.add(itm);
5185 }
5186 }
5187
5188 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5189
5190 if(get_bit(quest_rules,qr_MORESOUNDS))
5191 {
5192 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5193 {
5194 if (combobuf[cid].usrflags&cflag3)
5195 {
5196 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5197 }
5198 }
5199 else
5200 {
5201 if (combobuf[cid].usrflags&cflag3)
5202 {
5203 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5204 }
5205 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5206 }
5207 }
5208
5209 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5210 if(decotype > 3) decotype = 0;
5211 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5212 switch(decotype)
5213 {
5214 case -2: break; //nothing
5215 case -1:
5216 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5217 break;
5218 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5219 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5220 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5221 }
5222 }
5223
5224 if(!ignoreffc)
5225 {
5226 if(!isTouchyType(type2) && !get_bit(quest_rules, qr_CONT_SWORD_TRIGGERS)) set_bit(ffcgrid, current_ffcombo, 1);
5227
5228 if(isCuttableItemType(type2))
5229 {
5230 int32_t it=-1;
5231 int32_t thedropset = -1;
5232 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5233 {
5234 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5235 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5236 else
5237 {
5238 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5239 it = select_dropitem(thedropset);
5240 }
5241 }
5242 else
5243 {
5244 it = select_dropitem(12);
5245 thedropset = 12;
5246 }
5247
5248 if(it!=-1 && itemsbuf[it].family != itype_misc) // Don't drop non-gameplay items
5249 {
5250 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5251 itm->from_dropset = thedropset;
5252 items.add(itm);
5253 }
5254 }
5255
5256 if(get_bit(quest_rules,qr_MORESOUNDS))
5257 {
5258 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5259 {
5260 if (combobuf[cid].usrflags&cflag3)
5261 {
5262 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5263 }
5264 }
5265 else
5266 {
5267 if (combobuf[cid].usrflags&cflag3)
5268 {
5269 sfx(combobuf[cid].attribytes[2],int32_t(bx));
5270 }
5271 else sfx(QMisc.miscsfx[sfxBUSHGRASS],int32_t(bx));
5272 }
5273 }
5274
5275 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5276 if(decotype > 3) decotype = 0;
5277 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5278 switch(decotype)
5279 {
5280 case -2: break; //nothing
5281 case -1:
5282 decorations.add(new comboSprite((zfix)fx, (zfix)fy, 0, 0, combobuf[cid].attribytes[0]));
5283 break;
5284 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5285 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5286 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5287 }
5288 }
5289 }
5290
5291 //TODO: Boomerang that cuts bushes. -L
5292 /*void HeroClass::slash_bush()
5293 {
5294
5295 }*/
5296
5297 24562 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5298 {
5299 //keep things inside the screen boundaries
5300 24562 bx=vbound(bx, 0, 255);
5301 24562 by=vbound(by, 0, 176);
5302 24562 int32_t fx=vbound(bx, 0, 255);
5303 24562 int32_t fy=vbound(by, 0, 176);
5304 24562 int32_t cid = MAPCOMBO(bx,by);
5305
5306 //first things first
5307
2/4
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24562 times.
24562 if(z>8||fakez>8) return;
5308
5309 //find out which combo row/column the coordinates are in
5310 24562 bx &= 0xF0;
5311 24562 by &= 0xF0;
5312
5313 24562 int32_t flag = MAPFLAG(bx,by);
5314 24562 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5315 24562 int32_t flag3=0;
5316 24562 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5317 24562 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5318 24562 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5319 24562 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5320
5321
4/8
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24562 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24562 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 24562 times.
24562 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5322 flag3=mfWAND;
5323
5324
4/8
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24562 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24562 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 24562 times.
24562 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5325 flag3=mfSTRIKE;
5326
5327 24562 int32_t i = (bx>>4) + by;
5328
5329
6/12
✓ Branch 0 taken 24562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24562 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24562 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24562 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24562 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 24562 times.
✗ Branch 11 not taken.
24562 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5330 24562 return;
5331
5332 if(i > 175)
5333 return;
5334
5335 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5336
5337 //findentrance(bx,by,mfWAND,true);
5338 //findentrance(bx,by,mfSTRIKE,true);
5339 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5340 {
5341 if(flag3==mfWAND||flag3==mfSTRIKE)
5342 {
5343 findentrance(fx,fy,mfWAND,true);
5344 findentrance(fx,fy,mfSTRIKE,true);
5345 }
5346 }
5347
5348 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5349 24562 }
5350
5351 204 void HeroClass::check_pound_block(int32_t bx, int32_t by)
5352 {
5353 //keep things inside the screen boundaries
5354 204 bx=vbound(bx, 0, 255);
5355 204 by=vbound(by, 0, 176);
5356 204 int32_t fx=vbound(bx, 0, 255);
5357 204 int32_t fy=vbound(by, 0, 176);
5358 204 int32_t cid = MAPCOMBO(bx,by);
5359
5360 //first things first
5361
2/4
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 204 times.
204 if(z>8||fakez>8) return;
5362
5363 //find out which combo row/column the coordinates are in
5364 204 bx &= 0xF0;
5365 204 by &= 0xF0;
5366
5367 204 int32_t type = COMBOTYPE(bx,by);
5368 204 int32_t type2 = FFCOMBOTYPE(fx,fy);
5369 204 int32_t flag = MAPFLAG(bx,by);
5370 204 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5371 204 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5372 204 int32_t i = (bx>>4) + by;
5373
5374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 if(i > 175)
5375 return;
5376
5377 204 bool ignorescreen=false;
5378 204 bool ignoreffc=false;
5379 204 bool pound=false;
5380
5381
6/10
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 175 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 175 times.
204 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5382 175 ignorescreen = true; // Affect only FFCs
5383
5384
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 14 times.
204 if(get_bit(screengrid, i) != 0)
5385 14 ignorescreen = true;
5386
5387 204 int32_t current_ffcombo = getFFCAt(fx,fy);
5388
5389
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 203 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
204 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5390 203 ignoreffc = true;
5391
5392
3/6
✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 204 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 204 times.
204 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5393 204 ignoreffc = true;
5394
5395
3/4
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 183 times.
204 if(ignorescreen && ignoreffc) // Nothing to do.
5396 183 return;
5397
5398 21 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5399
5400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(!ignorescreen)
5401 {
5402
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5403 {
5404 findentrance(bx,by,mfHAMMER,true);
5405 findentrance(bx,by,mfSTRIKE,true);
5406 }
5407
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5408 {
5409 findentrance(bx,by,mfHAMMER,true);
5410 findentrance(bx,by,mfSTRIKE,true);
5411 }
5412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if((flag >= 16)&&(flag <= 31))
5413 {
5414 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5415 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5416 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5417 }
5418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 else if(flag == mfARMOS_SECRET)
5419 {
5420 s->data[i] = s->secretcombo[sSTAIRS];
5421 s->cset[i] = s->secretcset[sSTAIRS];
5422 s->sflag[i] = s->secretflag[sSTAIRS];
5423 sfx(tmpscr->secretsfx);
5424 }
5425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21 else if((flag2 >= 16)&&(flag2 <= 31))
5426 {
5427 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5428 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5429 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5430 }
5431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 else if(flag2 == mfARMOS_SECRET)
5432 {
5433 s->data[i] = s->secretcombo[sSTAIRS];
5434 s->cset[i] = s->secretcset[sSTAIRS];
5435 s->sflag[i] = s->secretflag[sSTAIRS];
5436 sfx(tmpscr->secretsfx);
5437 }
5438 21 else pound = true;
5439 21 }
5440
5441
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(!ignoreffc)
5442 {
5443 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5444 {
5445 findentrance(fx,fy,mfHAMMER,true);
5446 findentrance(fx,fy,mfSTRIKE,true);
5447 }
5448 else
5449 {
5450 s->ffcs[current_ffcombo].incData(1);
5451 }
5452 }
5453
5454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(!ignorescreen)
5455 {
5456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(pound)
5457 21 s->data[i]+=1;
5458
5459 21 set_bit(screengrid,i,1);
5460
5461
2/8
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
21 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5462 {
5463 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5464 sfx(tmpscr->secretsfx);
5465 }
5466
5467
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
21 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5468 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5469
5470 21 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5471 21 }
5472
5473
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(!ignoreffc)
5474 {
5475 set_bit(ffcgrid,current_ffcombo,1);
5476
5477 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5478 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5479 }
5480
5481 21 return;
5482 204 }
5483
5484
5485 void HeroClass::check_wand_block(weapon *w)
5486 {
5487
5488 int32_t par_item = w->parentitem;
5489 al_trace("check_wand_block(weapon *w): par_item is: %d\n", par_item);
5490 int32_t usewpn = -1;
5491 if ( par_item > -1 )
5492 {
5493 usewpn = itemsbuf[par_item].useweapon;
5494 }
5495 else if ( par_item == -1 && w->ScriptGenerated )
5496 {
5497 usewpn = w->useweapon;
5498 }
5499 al_trace("check_wand_block(weapon *w): usewpn is: %d\n", usewpn);
5500 if(usewpn != wWand) return;
5501
5502
5503 int32_t bx = 0, by = 0;
5504 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5505 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5506
5507 //keep things inside the screen boundaries
5508 bx=vbound(bx, 0, 255);
5509 by=vbound(by, 0, 176);
5510 int32_t fx=vbound(bx, 0, 255);
5511 int32_t fy=vbound(by, 0, 176);
5512 int32_t cid = MAPCOMBO(bx,by);
5513 //first things first
5514 if(z>8||fakez>8) return;
5515
5516 //find out which combo row/column the coordinates are in
5517 bx &= 0xF0;
5518 by &= 0xF0;
5519
5520 int32_t flag = MAPFLAG(bx,by);
5521 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5522 int32_t flag3=0;
5523 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5524 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5525 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5526 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5527
5528 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5529 flag3=mfWAND;
5530
5531 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5532 flag3=mfSTRIKE;
5533
5534 int32_t i = (bx>>4) + by;
5535
5536 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5537 return;
5538
5539 if(i > 175)
5540 return;
5541
5542 //mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5543
5544 //findentrance(bx,by,mfWAND,true);
5545 //findentrance(bx,by,mfSTRIKE,true);
5546 if((findentrance(bx,by,mfWAND,true)==false)&&(findentrance(bx,by,mfSTRIKE,true)==false))
5547 {
5548 if(flag3==mfWAND||flag3==mfSTRIKE)
5549 {
5550 findentrance(fx,fy,mfWAND,true);
5551 findentrance(fx,fy,mfSTRIKE,true);
5552 }
5553 }
5554
5555 //putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5556 }
5557
5558 void HeroClass::check_pound_block(weapon *w)
5559 {
5560
5561 int32_t par_item = w->parentitem;
5562 al_trace("check_pound_block(weapon *w): par_item is: %d\n", par_item);
5563 int32_t usewpn = -1;
5564 if ( par_item > -1 )
5565 {
5566 usewpn = itemsbuf[par_item].useweapon;
5567 }
5568 else if ( par_item == -1 && w->ScriptGenerated )
5569 {
5570 usewpn = w->useweapon;
5571 }
5572 al_trace("check_pound_block(weapon *w): usewpn is: %d\n", usewpn);
5573 if(usewpn != wHammer) return;
5574
5575
5576 int32_t bx = 0, by = 0;
5577 bx = ((int32_t)w->x) + (((int32_t)w->hxsz)/2);
5578 by = ((int32_t)w->y) + (((int32_t)w->hysz)/2);
5579 //keep things inside the screen boundaries
5580 bx=vbound(bx, 0, 255);
5581 by=vbound(by, 0, 176);
5582 int32_t fx=vbound(bx, 0, 255);
5583 int32_t fy=vbound(by, 0, 176);
5584 int32_t cid = MAPCOMBO(bx,by);
5585 //first things first
5586 if(z>8||fakez>8) return;
5587
5588 //find out which combo row/column the coordinates are in
5589 bx &= 0xF0;
5590 by &= 0xF0;
5591
5592 int32_t type = COMBOTYPE(bx,by);
5593 int32_t type2 = FFCOMBOTYPE(fx,fy);
5594 int32_t flag = MAPFLAG(bx,by);
5595 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5596 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5597 int32_t i = (bx>>4) + by;
5598
5599 if(i > 175)
5600 return;
5601
5602 bool ignorescreen=false;
5603 bool ignoreffc=false;
5604 bool pound=false;
5605
5606 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5607 ignorescreen = true; // Affect only FFCs
5608
5609 if(get_bit(screengrid, i) != 0)
5610 ignorescreen = true;
5611
5612 int32_t current_ffcombo = getFFCAt(fx,fy);
5613
5614 if(current_ffcombo == -1 || get_bit(ffcgrid, current_ffcombo) != 0)
5615 ignoreffc = true;
5616
5617 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5618 ignoreffc = true;
5619
5620 if(ignorescreen && ignoreffc) // Nothing to do.
5621 return;
5622
5623 mapscr *s = tmpscr + ((currscr>=128) ? 1 : 0);
5624
5625 if(!ignorescreen)
5626 {
5627 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5628 {
5629 findentrance(bx,by,mfHAMMER,true);
5630 findentrance(bx,by,mfSTRIKE,true);
5631 }
5632 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5633 {
5634 findentrance(bx,by,mfHAMMER,true);
5635 findentrance(bx,by,mfSTRIKE,true);
5636 }
5637 else if((flag >= 16)&&(flag <= 31))
5638 {
5639 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5640 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5641 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5642 }
5643 else if(flag == mfARMOS_SECRET)
5644 {
5645 s->data[i] = s->secretcombo[sSTAIRS];
5646 s->cset[i] = s->secretcset[sSTAIRS];
5647 s->sflag[i] = s->secretflag[sSTAIRS];
5648 sfx(tmpscr->secretsfx);
5649 }
5650 else if((flag2 >= 16)&&(flag2 <= 31))
5651 {
5652 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5653 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5654 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5655 }
5656 else if(flag2 == mfARMOS_SECRET)
5657 {
5658 s->data[i] = s->secretcombo[sSTAIRS];
5659 s->cset[i] = s->secretcset[sSTAIRS];
5660 s->sflag[i] = s->secretflag[sSTAIRS];
5661 sfx(tmpscr->secretsfx);
5662 }
5663 else pound = true;
5664 }
5665
5666 if(!ignoreffc)
5667 {
5668 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5669 {
5670 findentrance(fx,fy,mfHAMMER,true);
5671 findentrance(fx,fy,mfSTRIKE,true);
5672 }
5673 else
5674 {
5675 s->ffcs[current_ffcombo].incData(1);
5676 }
5677 }
5678
5679 if(!ignorescreen)
5680 {
5681 if(pound)
5682 s->data[i]+=1;
5683
5684 set_bit(screengrid,i,1);
5685
5686 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
5687 {
5688 items.add(new item((zfix)bx, (zfix)by, (zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5689 sfx(tmpscr->secretsfx);
5690 }
5691
5692 if(type==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5693 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5694
5695 putcombo(scrollbuf,(i&15)<<4,i&0xF0,s->data[i],s->cset[i]);
5696 }
5697
5698 if(!ignoreffc)
5699 {
5700 set_bit(ffcgrid,current_ffcombo,1);
5701
5702 if(type2==cPOUND && get_bit(quest_rules,qr_MORESOUNDS))
5703 sfx(QMisc.miscsfx[sfxHAMMERPOUND],int32_t(bx));
5704 }
5705
5706 return;
5707 }
5708
5709 //defend results should match defence types.
5710 //RETURN VALUES:
5711 // -1 iGNORE WEAPON
5712 // 0 No effects
5713 // 1 Effects, weapon is not ignored or removed
5714 5903 int32_t HeroClass::defend(weapon *w)
5715 {
5716 5903 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5717
1/25
✓ Branch 0 taken 5903 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
5903 switch(def)
5718 {
5719 5903 case edNORMAL: return 1;
5720 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5721 {
5722 w->power *= 0.5;
5723 return 1;
5724 }
5725 case edQUARTDAMAGE:
5726 {
5727 w->power *= 0.25;
5728 return 1;
5729 }
5730 case edSTUNONLY:
5731 {
5732 setStunClock(120);
5733 return 1;
5734 }
5735 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5736 {
5737 if (w->power > 0)
5738 {
5739 setStunClock(120);
5740 return 1;
5741 }
5742 else
5743 {
5744 sfx(WAV_CHINK,pan(int32_t(x)));
5745 w->dead = 0;
5746 return -1;
5747 }
5748 }
5749 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5750 {
5751 if (w->power > 0)
5752 {
5753 setStunClock(120);
5754 return 1;
5755 }
5756 else
5757 {
5758 return -1;
5759 }
5760 }
5761 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5762 {
5763 if (w->power < 1)
5764 {
5765 sfx(WAV_CHINK,pan(int32_t(x)));
5766 w->dead = 0;
5767 return -1;
5768 }
5769 else
5770 {
5771 return 1;
5772 }
5773 }
5774 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5775 {
5776 if (w->power < 2)
5777 {
5778 sfx(WAV_CHINK,pan(int32_t(x)));
5779 w->dead = 0;
5780 return -1;
5781 }
5782 else
5783 {
5784 return 1;
5785 }
5786 }
5787 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5788 {
5789 if (w->power < 4)
5790 {
5791 sfx(WAV_CHINK,pan(int32_t(x)));
5792 w->dead = 0;
5793 return -1;
5794 }
5795 else
5796 {
5797 return 1;
5798 }
5799 }
5800 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5801 {
5802 if (w->power < 6)
5803 {
5804 sfx(WAV_CHINK,pan(int32_t(x)));
5805 w->dead = 0;
5806 return -1;
5807 }
5808 else
5809 {
5810 return 1;
5811 }
5812 }
5813 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5814 {
5815 if (w->power < 8)
5816 {
5817 sfx(WAV_CHINK,pan(int32_t(x)));
5818 w->dead = 0;
5819 return -1;
5820 }
5821 else
5822 {
5823 return 1;
5824 }
5825 }
5826 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5827 {
5828 sfx(WAV_CHINK,pan(int32_t(x)));
5829 w->dead = 0;
5830 return -1;
5831 }
5832 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5833 {
5834 if (w->power < 1)
5835 {
5836 return -1;
5837 }
5838 else return 1;
5839 }
5840 case edIGNORE: // : IMPLEMENTED : Do Nothing
5841 {
5842 return -1;
5843 }
5844 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5845 {
5846 game->set_life(0);
5847 return 1;
5848 }
5849 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5850 {
5851 if (w->power < 10)
5852 {
5853 sfx(WAV_CHINK,pan(int32_t(x)));
5854 w->dead = 0;
5855 return -1;
5856 }
5857 else
5858 {
5859 return 1;
5860 }
5861 }
5862 case ed2x: // : IMPLEMENTED : Double damage.
5863 {
5864 w->power *= 2;
5865 return 1;
5866 }
5867 case ed3x: // : IMPLEMENTED : Triple Damage.
5868 {
5869 w->power *= 3;
5870 return 1;
5871 }
5872 case ed4x: // : IMPLEMENTED : 4x damage.
5873 {
5874 w->power *= 4;
5875 return 1;
5876 }
5877 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5878 {
5879 //sfx(WAV_HEAL,pan(int32_t(x)));
5880 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5881 w->dead = 0;
5882 return -1;
5883 }
5884
5885 case edFREEZE: return 1; //Not IMPLEMENTED
5886
5887 case edLEVELDAMAGE: //Damage * item level
5888 {
5889 w->power *= w->family_level;
5890 return 1;
5891 }
5892 case edLEVELREDUCTION: //Damage / item level
5893 {
5894 if ( w->family_level > 0 )
5895 {
5896 w->power /= w->family_level;
5897 }
5898 else w->power = 0;
5899 return 1;
5900 }
5901
5902 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5903 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5904 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5905 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5906
5907 //edSHOCK, //buzz blob
5908
5909
5910 case edBREAKSHIELD: //destroy the player's present shield
5911 {
5912 w->power = 0;
5913 w->dead = 0;
5914 int32_t itemid = getCurrentShield();
5915 //sfx(WAV_BREAKSHIELD,pan(int32_t(x)));
5916 if(itemsbuf[itemid].flags&ITEM_EDIBLE)
5917 game->set_item(itemid, false);
5918 //Remove Hero's shield
5919 return -1;
5920 }
5921
5922
5923
5924 default: return 0;
5925 }
5926 5903 }
5927 ALLEGRO_COLOR HeroClass::hitboxColor(byte opacity) const
5928 {
5929 return al_map_rgba(0,0,255,opacity);
5930 }
5931 5723 int32_t HeroClass::compareDir(int32_t other)
5932 {
5933
5/6
✓ Branch 0 taken 5718 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5718 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 5721 times.
5723 if(other != NORMAL_DIR(other))
5934 2 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5935 5721 int32_t ret = 0;
5936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5721 times.
5721 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5937
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1214 times.
✓ Branch 2 taken 921 times.
✓ Branch 3 taken 1810 times.
✓ Branch 4 taken 1776 times.
5721 switch(d)
5938 {
5939 case up:
5940 {
5941
3/3
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 485 times.
1214 switch(X_DIR(other))
5942 {
5943 case left:
5944 480 ret |= CMPDIR_RIGHT;
5945 480 break;
5946 case right:
5947 485 ret |= CMPDIR_LEFT;
5948 485 break;
5949 }
5950
3/3
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 895 times.
1214 switch(Y_DIR(other))
5951 {
5952 case up:
5953 210 ret |= CMPDIR_BACK;
5954 210 break;
5955 case down:
5956 895 ret |= CMPDIR_FRONT;
5957 895 break;
5958 }
5959 1214 break;
5960 }
5961 case down:
5962 {
5963
3/3
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 375 times.
921 switch(X_DIR(other))
5964 {
5965 case left:
5966 302 ret |= CMPDIR_LEFT;
5967 302 break;
5968 case right:
5969 375 ret |= CMPDIR_RIGHT;
5970 375 break;
5971 }
5972
3/3
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 647 times.
✓ Branch 2 taken 161 times.
921 switch(Y_DIR(other))
5973 {
5974 case up:
5975 647 ret |= CMPDIR_FRONT;
5976 647 break;
5977 case down:
5978 161 ret |= CMPDIR_BACK;
5979 161 break;
5980 }
5981 921 break;
5982 }
5983 case left:
5984 {
5985
3/3
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 263 times.
✓ Branch 2 taken 1477 times.
1810 switch(X_DIR(other))
5986 {
5987 case left:
5988 263 ret |= CMPDIR_BACK;
5989 263 break;
5990 case right:
5991 1477 ret |= CMPDIR_FRONT;
5992 1477 break;
5993 }
5994
3/3
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 570 times.
✓ Branch 2 taken 634 times.
1810 switch(Y_DIR(other))
5995 {
5996 case up:
5997 570 ret |= CMPDIR_LEFT;
5998 570 break;
5999 case down:
6000 634 ret |= CMPDIR_RIGHT;
6001 634 break;
6002 }
6003 1810 break;
6004 }
6005 case right:
6006 {
6007
3/3
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1466 times.
✓ Branch 2 taken 240 times.
1776 switch(X_DIR(other))
6008 {
6009 case left:
6010 1466 ret |= CMPDIR_FRONT;
6011 1466 break;
6012 case right:
6013 240 ret |= CMPDIR_BACK;
6014 240 break;
6015 }
6016
3/3
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 650 times.
1776 switch(Y_DIR(other))
6017 {
6018 case up:
6019 480 ret |= CMPDIR_RIGHT;
6020 480 break;
6021 case down:
6022 650 ret |= CMPDIR_LEFT;
6023 650 break;
6024 }
6025 1776 break;
6026 }
6027 }
6028 5721 return ret;
6029 5723 }
6030
6031 5723 bool compareShield(int32_t cmpdir, itemdata const& shield)
6032 {
6033
1/2
✓ Branch 0 taken 5723 times.
✗ Branch 1 not taken.
5723 bool standard = !(shield.flags&ITEM_FLAG9) || usingActiveShield();
6034
1/2
✓ Branch 0 taken 5723 times.
✗ Branch 1 not taken.
5723 if(standard) //Use standard sides, either a passive shield, or a held active shield
6035 {
6036
3/4
✓ Branch 0 taken 4485 times.
✓ Branch 1 taken 1238 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4485 times.
5723 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG1))
6037 4485 return true;
6038
3/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 874 times.
✗ Branch 3 not taken.
1238 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG2))
6039 return true;
6040
3/4
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 711 times.
✓ Branch 2 taken 527 times.
✗ Branch 3 not taken.
1238 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG3))
6041 return true;
6042
3/4
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 678 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 560 times.
1238 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG4))
6043 return true;
6044 1238 }
6045 else //Active Shield that is NOT held down
6046 {
6047 if((cmpdir&CMPDIR_FRONT) && (shield.flags&ITEM_FLAG5))
6048 return true;
6049 else if((cmpdir&CMPDIR_BACK) && (shield.flags&ITEM_FLAG6))
6050 return true;
6051 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&ITEM_FLAG7))
6052 return true;
6053 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&ITEM_FLAG8))
6054 return true;
6055 }
6056 1238 return false;
6057 5723 }
6058
6059 4618358 int32_t HeroClass::EwpnHit()
6060 {
6061
2/2
✓ Branch 0 taken 4615878 times.
✓ Branch 1 taken 3709934 times.
8325812 for(int32_t i=0; i<Ewpns.Count(); i++)
6062 {
6063
2/2
✓ Branch 0 taken 3704031 times.
✓ Branch 1 taken 5903 times.
3709934 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6064 {
6065 5903 weapon *ew = (weapon*)(Ewpns.spr(i));
6066
6067
3/6
✓ Branch 0 taken 5903 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5903 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5903 times.
5903 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6068 break;
6069
6070 5903 int32_t stompid = current_item_id(itype_stompboots);
6071
6072
5/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
5903 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6073
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((z+fakez) > (ew->z+(ew->fakez))) ||
6074
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
6075 {
6076 itemdata const& stomp = itemsbuf[stompid];
6077 bool remove = false;
6078 switch(ew->id)
6079 {
6080 case ewFireball2:
6081 case ewFireball:
6082 if(ew->type & 1) //Boss fireball
6083 {
6084 if(stomp.misc2 & (shFIREBALL2))
6085 remove = true;
6086 }
6087 else
6088 {
6089 if(stomp.misc2 & (shFIREBALL))
6090 remove = true;
6091 }
6092
6093 break;
6094
6095 case ewMagic:
6096 if((stomp.misc2 & shMAGIC))
6097 remove = true;
6098 break;
6099
6100 case ewSword:
6101 if((stomp.misc2 & shSWORD))
6102 remove = true;
6103
6104 break;
6105
6106 case ewFlame:
6107 if((stomp.misc2 & shFLAME))
6108 remove = true;
6109
6110 break;
6111
6112 case ewRock:
6113 if((stomp.misc2 & shROCK))
6114 remove = true;
6115
6116 break;
6117
6118 case ewArrow:
6119 if((stomp.misc2 & shARROW))
6120 remove = true;
6121
6122 break;
6123
6124 case ewBrang:
6125 if((stomp.misc2 & shBRANG))
6126 remove = true;
6127
6128 break;
6129
6130 default: // Just throw the script weapons in here...
6131 if(ew->id>=wScript1 && ew->id<=wScript10)
6132 {
6133 if((stomp.misc2 & shSCRIPT))
6134 remove = true;
6135 }
6136
6137 break;
6138 }
6139 if (remove)
6140 {
6141 ew->onhit(false);
6142 sfx(WAV_CHINK,pan(x.getInt()));
6143 continue;
6144 }
6145 }
6146
6147 5903 int32_t defresult = defend(ew);
6148
1/2
✓ Branch 0 taken 5903 times.
✗ Branch 1 not taken.
5903 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6149
6150
2/2
✓ Branch 0 taken 5902 times.
✓ Branch 1 taken 1 times.
5903 if(ew->id==ewWind)
6151 {
6152 1 xofs=1000;
6153 1 action=freeze; FFCore.setHeroAction(freeze);
6154 1 ew->misc=999; // in enemy wind
6155 1 attackclk=0;
6156 1 return -1;
6157 }
6158
6159
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5891 times.
5902 switch(ew->id)
6160 {
6161 case ewLitBomb:
6162 case ewBomb:
6163 case ewLitSBomb:
6164 case ewSBomb:
6165 11 return i;
6166 }
6167
6168 5891 int32_t itemid = getCurrentShield(false);
6169
4/6
✓ Branch 0 taken 5721 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 5721 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5721 times.
5891 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6170 5721 itemdata const& shield = itemsbuf[itemid];
6171 5721 auto cmpdir = compareDir(ew->dir);
6172 5721 bool hitshield = compareShield(cmpdir, shield);
6173
6174
6175
12/18
✓ Branch 0 taken 4485 times.
✓ Branch 1 taken 1236 times.
✓ Branch 2 taken 3691 times.
✓ Branch 3 taken 794 times.
✓ Branch 4 taken 3691 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3673 times.
✓ Branch 7 taken 18 times.
✓ Branch 8 taken 3673 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3673 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3673 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3673 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 3673 times.
5721 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF)
6176 {
6177 2048 return i;
6178 }
6179
6180 3673 paymagiccost(itemid);
6181
6182 3673 bool reflect = false;
6183
6184
7/8
✓ Branch 0 taken 2100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 498 times.
✓ Branch 3 taken 234 times.
✓ Branch 4 taken 349 times.
✓ Branch 5 taken 169 times.
✓ Branch 6 taken 178 times.
✓ Branch 7 taken 145 times.
3673 switch(ew->id)
6185 {
6186 case ewFireball2:
6187 case ewFireball:
6188
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1962 times.
2100 if(ew->type & 1) //Boss fireball
6189 {
6190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!(shield.misc1 & (shFIREBALL2)))
6191 138 return i;
6192
6193 reflect = ((shield.misc2 & shFIREBALL2) != 0);
6194 }
6195 else
6196 {
6197
2/2
✓ Branch 0 taken 1912 times.
✓ Branch 1 taken 50 times.
1962 if(!(shield.misc1 & (shFIREBALL)))
6198 50 return i;
6199
6200 1912 reflect = ((shield.misc2 & shFIREBALL) != 0);
6201 }
6202
6203 1912 break;
6204
6205 case ewMagic:
6206
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 8 times.
498 if(!(shield.misc1 & shMAGIC))
6207 8 return i;
6208
6209 490 reflect = ((shield.misc2 & shMAGIC) != 0);
6210 490 break;
6211
6212 case ewSword:
6213
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 8 times.
234 if(!(shield.misc1 & shSWORD))
6214 8 return i;
6215
6216 226 reflect = ((shield.misc2 & shSWORD) != 0);
6217 226 break;
6218
6219 case ewFlame:
6220
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 46 times.
349 if(!(shield.misc1 & shFLAME))
6221 46 return i;
6222
6223 303 reflect = ((shield.misc2 & shFLAME) != 0); // Actually isn't reflected.
6224 303 break;
6225
6226 case ewRock:
6227
1/2
✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
169 if(!(shield.misc1 & shROCK))
6228 return i;
6229
6230 169 reflect = (shield.misc2 & shROCK);
6231 169 break;
6232
6233 case ewArrow:
6234
1/2
✓ Branch 0 taken 178 times.
✗ Branch 1 not taken.
178 if(!(shield.misc1 & shARROW))
6235 return i;
6236
6237 178 reflect = ((shield.misc2 & shARROW) != 0); // Actually isn't reflected.
6238 178 break;
6239
6240 case ewBrang:
6241
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if(!(shield.misc1 & shBRANG))
6242 return i;
6243
6244 145 break;
6245
6246 default: // Just throw the script weapons in here...
6247 if(ew->id>=wScript1 && ew->id<=wScript10)
6248 {
6249 if(!(shield.misc1 & shSCRIPT))
6250 return i;
6251
6252 reflect = ((shield.misc2 & shSCRIPT) != 0);
6253 }
6254
6255 break;
6256 }
6257
6258
3/4
✓ Branch 0 taken 1004 times.
✓ Branch 1 taken 2419 times.
✓ Branch 2 taken 1004 times.
✗ Branch 3 not taken.
3423 if(reflect && (ew->unblockable&WPNUNB_REFL))
6259 reflect = false;
6260
3/4
✓ Branch 0 taken 2419 times.
✓ Branch 1 taken 1004 times.
✓ Branch 2 taken 2419 times.
✗ Branch 3 not taken.
3423 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6261 return i;
6262
6263 3423 int32_t oldid = ew->id;
6264 3423 ew->onhit(false, reflect ? 2 : 1, dir);
6265
6266
2/2
✓ Branch 0 taken 2419 times.
✓ Branch 1 taken 1004 times.
3423 if(ew->id != oldid) // changed type from ewX to wX
6267 {
6268 // ew->power*=game->get_hero_dmgmult();
6269 1004 Lwpns.add(ew);
6270 1004 Ewpns.remove(ew);
6271 1004 ew->isLWeapon = true; //Make sure this gets set everywhere!
6272 1004 }
6273
6274
2/2
✓ Branch 0 taken 3111 times.
✓ Branch 1 taken 312 times.
3423 if(ew->id==wRefMagic)
6275 {
6276 312 ew->ignoreHero=true;
6277 312 ew->ignorecombo=-1;
6278 312 }
6279
6280 3423 sfx(shield.usesound,pan(x.getInt()));
6281 3423 }
6282 3707454 }
6283
6284 4615878 return -1;
6285 4618358 }
6286
6287 4618360 int32_t HeroClass::LwpnHit() //only here to check magic hits
6288 {
6289
2/2
✓ Branch 0 taken 4528303 times.
✓ Branch 1 taken 2080083 times.
6608386 for(int32_t i=0; i<Lwpns.Count(); i++)
6290
2/2
✓ Branch 0 taken 1990026 times.
✓ Branch 1 taken 90057 times.
2080083 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6291 {
6292 90057 weapon *lw = (weapon*)(Lwpns.spr(i));
6293
6294
2/2
✓ Branch 0 taken 86974 times.
✓ Branch 1 taken 3083 times.
90057 if((lw->ignoreHero)==true)
6295 3083 break;
6296
6297
5/8
✓ Branch 0 taken 86974 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 86972 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 86972 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 86972 times.
86974 if (!(lw->id == wRefFireball || lw->id == wRefMagic || lw->id == wRefBeam || lw->id == wRefRock)) return -1;
6298 2 int32_t itemid = getCurrentShield(false);
6299
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6300 2 itemdata const& shield = itemsbuf[itemid];
6301 2 auto cmpdir = compareDir(lw->dir);
6302 2 bool hitshield = compareShield(cmpdir, shield);
6303 2 bool reflect = false;
6304
6305
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 switch(lw->id)
6306 {
6307 case wRefFireball:
6308 if(itemid<0)
6309 return i;
6310
6311 if(lw->type & 1) //Boss fireball
6312 return i;
6313
6314 if(!(shield.misc1 & (shFIREBALL)))
6315 return i;
6316
6317 reflect = ((shield.misc2 & shFIREBALL) != 0);
6318 break;
6319
6320 case wRefMagic:
6321
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemid<0)
6322 return i;
6323
6324
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(shield.misc1 & shMAGIC))
6325 return i;
6326
6327 2 reflect = ((shield.misc2 & shMAGIC) != 0);
6328 2 break;
6329
6330 case wRefBeam:
6331 if(itemid<0)
6332 return i;
6333
6334 if(!(shield.misc1 & shSWORD))
6335 return i;
6336
6337 reflect = ((shield.misc2 & shSWORD) != 0);
6338 break;
6339
6340 case wRefRock:
6341 if(itemid<0)
6342 return i;
6343
6344 if(!(shield.misc1 & shROCK))
6345 return i;
6346
6347 reflect = (shield.misc2 & shROCK);
6348 break;
6349
6350 default:
6351 return -1;
6352 }
6353
6354
1/14
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
2 if(!hitshield || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || hopclk==0xFF)
6355 2 return i;
6356
6357 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid))) return i;
6358
6359 paymagiccost(itemid);
6360
6361 lw->onhit(false, 1+reflect, dir);
6362 lw->ignoreHero=true;
6363 lw->ignorecombo=-1;
6364 sfx(shield.usesound,pan(x.getInt()));
6365 }
6366
6367 4531386 return -1;
6368 4618360 }
6369
6370 8425159 void HeroClass::checkhit()
6371 {
6372
2/2
✓ Branch 0 taken 3272646 times.
✓ Branch 1 taken 5152513 times.
8425159 if(checkhero==true)
6373 {
6374
2/2
✓ Branch 0 taken 267617 times.
✓ Branch 1 taken 4884896 times.
5152513 if(hclk>0)
6375 {
6376 267617 --hclk;
6377 267617 }
6378
6379
1/2
✓ Branch 0 taken 5152513 times.
✗ Branch 1 not taken.
5152513 if(NayrusLoveShieldClk>0)
6380 {
6381 --NayrusLoveShieldClk;
6382
6383 if(NayrusLoveShieldClk == 0 && nayruitem != -1)
6384 {
6385 stop_sfx(itemsbuf[nayruitem].usesound);
6386 stop_sfx(itemsbuf[nayruitem].usesound+1);
6387 nayruitem = -1;
6388 }
6389 else if(get_bit(quest_rules,qr_MORESOUNDS) && !(NayrusLoveShieldClk&0xF00) && nayruitem != -1)
6390 {
6391 stop_sfx(itemsbuf[nayruitem].usesound);
6392 cont_sfx(itemsbuf[nayruitem].usesound+1);
6393 }
6394 }
6395 5152513 }
6396
6397
4/4
✓ Branch 0 taken 5101732 times.
✓ Branch 1 taken 3323427 times.
✓ Branch 2 taken 5098642 times.
✓ Branch 3 taken 3090 times.
8425159 if(hclk<39 && action==gothit)
6398 {
6399 3090 action=none; FFCore.setHeroAction(none);
6400 3090 }
6401
6402
5/6
✓ Branch 0 taken 5101732 times.
✓ Branch 1 taken 3323427 times.
✓ Branch 2 taken 5101687 times.
✓ Branch 3 taken 45 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5101687 times.
8425159 if(hclk<39 && (action==swimhit || action == sideswimhit))
6403 {
6404 45 SetSwim();
6405 45 }
6406
6407
4/4
✓ Branch 0 taken 45155 times.
✓ Branch 1 taken 8380004 times.
✓ Branch 2 taken 12329 times.
✓ Branch 3 taken 32826 times.
8425159 if(hclk>=40 && action==gothit)
6408 {
6409 32826 int val = check_pitslide();
6410
4/4
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 32552 times.
✓ Branch 2 taken 32946 times.
✓ Branch 3 taken 32672 times.
32826 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6411 {
6412
2/2
✓ Branch 0 taken 131784 times.
✓ Branch 1 taken 32946 times.
164730 for(int32_t i=0; i<4; i++)
6413 {
6414
5/5
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 28052 times.
✓ Branch 2 taken 32124 times.
✓ Branch 3 taken 33984 times.
✓ Branch 4 taken 37528 times.
131784 switch(hitdir)
6415 {
6416 case up:
6417
6/6
✓ Branch 0 taken 1750 times.
✓ Branch 1 taken 26302 times.
✓ Branch 2 taken 1874 times.
✓ Branch 3 taken 24428 times.
✓ Branch 4 taken 1762 times.
✓ Branch 5 taken 26290 times.
28052 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6418 {
6419 1762 action=none; FFCore.setHeroAction(none);
6420 1762 }
6421
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26286 times.
26290 else if (val == -1) --y;
6422
6423 28052 break;
6424
6425 case down:
6426
6/6
✓ Branch 0 taken 2577 times.
✓ Branch 1 taken 29547 times.
✓ Branch 2 taken 2059 times.
✓ Branch 3 taken 27488 times.
✓ Branch 4 taken 2593 times.
✓ Branch 5 taken 29531 times.
32124 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6427 {
6428 2593 action=none; FFCore.setHeroAction(none);
6429 2593 }
6430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29531 times.
29531 else if (val == -1) ++y;
6431
6432 32124 break;
6433
6434 case left:
6435
7/8
✓ Branch 0 taken 32873 times.
✓ Branch 1 taken 1111 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32873 times.
✓ Branch 4 taken 778 times.
✓ Branch 5 taken 32095 times.
✓ Branch 6 taken 1115 times.
✓ Branch 7 taken 32869 times.
33984 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6436 {
6437 1115 action=none; FFCore.setHeroAction(none);
6438 1115 }
6439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32869 times.
32869 else if (val == -1) --x;
6440
6441 33984 break;
6442
6443 case right:
6444
7/8
✓ Branch 0 taken 36150 times.
✓ Branch 1 taken 1378 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36150 times.
✓ Branch 4 taken 35614 times.
✓ Branch 5 taken 536 times.
✓ Branch 6 taken 1386 times.
✓ Branch 7 taken 36142 times.
37528 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6445 {
6446 1386 action=none; FFCore.setHeroAction(none);
6447 1386 }
6448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36142 times.
36142 else if (val == -1) ++x;
6449
6450 37528 break;
6451 }
6452 131784 }
6453 32946 }
6454 33066 }
6455
6456
18/20
✓ Branch 0 taken 4890391 times.
✓ Branch 1 taken 3535008 times.
✓ Branch 2 taken 4890349 times.
✓ Branch 3 taken 42 times.
✓ Branch 4 taken 4884668 times.
✓ Branch 5 taken 5681 times.
✓ Branch 6 taken 4884005 times.
✓ Branch 7 taken 663 times.
✓ Branch 8 taken 4884005 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4884005 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4883857 times.
✓ Branch 13 taken 148 times.
✓ Branch 14 taken 4880739 times.
✓ Branch 15 taken 3118 times.
✓ Branch 16 taken 3776 times.
✓ Branch 17 taken 4876963 times.
✓ Branch 18 taken 3800906 times.
✓ Branch 19 taken 3804682 times.
8425399 if(hclk>0 || inlikelike == 1 || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6457 {
6458 7345566 return;
6459 }
6460
6461
2/2
✓ Branch 0 taken 6052292 times.
✓ Branch 1 taken 4876902 times.
10929194 for(int32_t i=0; i<Lwpns.Count(); i++)
6462 {
6463 6052292 sprite *s = Lwpns.spr(i);
6464 6052292 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6465 //if ( itemdbuf[parentitem].flags&ITEM_FLAGS3 ) //can damage Hero
6466 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6467
13/14
✓ Branch 0 taken 374601 times.
✓ Branch 1 taken 5677691 times.
✓ Branch 2 taken 1873009 times.
✓ Branch 3 taken 3804682 times.
✓ Branch 4 taken 1873009 times.
✓ Branch 5 taken 1931673 times.
✓ Branch 6 taken 1846994 times.
✓ Branch 7 taken 84679 times.
✓ Branch 8 taken 1846994 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 73226 times.
✓ Branch 11 taken 1773768 times.
✓ Branch 12 taken 39641 times.
✓ Branch 13 taken 33585 times.
6052292 if((!(itemid==-1&&get_bit(quest_rules,qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].family==itype_candle||itemsbuf[itemid].family==itype_book)&&(itemsbuf[itemid].flags & ITEM_FLAG3)))) && (scriptcoldet&1) && !fallclk && (!superman || !get_bit(quest_rules,qr_FIREPROOFHERO2)))
6468 {
6469
7/10
✓ Branch 0 taken 1759071 times.
✓ Branch 1 taken 48282 times.
✓ Branch 2 taken 48282 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 48264 times.
✓ Branch 8 taken 1807335 times.
✓ Branch 9 taken 18 times.
1807371 if(s->id==wFire && (superman ? (diagonalMovement?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6470
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 (itemid < 0 || itemsbuf[itemid].family!=itype_dinsfire))
6471 {
6472 18 std::vector<int32_t> &ev = FFCore.eventData;
6473 18 ev.clear();
6474 18 ev.push_back(lwpn_dp(i)*10000);
6475 18 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6476 18 ev.push_back(0);
6477 18 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6478 18 ev.push_back(48*10000);
6479 18 ev.push_back(ZSD_LWPN*10000);
6480 18 ev.push_back(s->getUID());
6481
6482 18 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6483 18 int32_t dmg = ev[0]/10000;
6484 18 bool nullhit = ev[2] != 0;
6485
6486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(nullhit) {ev.clear(); return;}
6487
6488 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6489 18 ev[0] = ringpower(dmg)*10000;
6490
6491 18 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6492 18 dmg = ev[0]/10000;
6493 18 int32_t hdir = ev[1]/10000;
6494 18 nullhit = ev[2] != 0;
6495 18 bool nayrulove = ev[3] != 0;
6496 18 int32_t iframes = ev[4] / 10000;
6497 18 ev.clear();
6498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(nullhit) return;
6499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!nayrulove)
6500 {
6501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 game->set_life(zc_max(game->get_life()-dmg,0));
6502 18 }
6503
6504 18 hitdir = hdir;
6505
6506
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
18 if (action != rafting && action != freeze && action != sideswimfreeze)
6507 {
6508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (IsSideSwim())
6509 {
6510 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6511 }
6512
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
18 else if (action == swimming || hopclk == 0xFF)
6513 {
6514 action=swimhit; FFCore.setHeroAction(swimhit);
6515 }
6516 else
6517 {
6518 18 action=gothit; FFCore.setHeroAction(gothit);
6519 }
6520 18 }
6521
6522
5/8
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 13 times.
18 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6523 {
6524 5 spins = charging = attackclk = 0;
6525 5 attack=none;
6526 5 tapping = false;
6527 5 }
6528
6529 18 hclk=iframes;
6530 18 sfx(getHurtSFX(),pan(x.getInt()));
6531 18 return;
6532 }
6533 1807335 }
6534
6535 // check enemy weapons true, 1, -1
6536 //
6537
2/2
✓ Branch 0 taken 2229811 times.
✓ Branch 1 taken 17781 times.
2306256 if((itemsbuf[itemid].flags & ITEM_FLAG6))
6538 {
6539
6/6
✓ Branch 0 taken 1717 times.
✓ Branch 1 taken 16064 times.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 1558 times.
✓ Branch 4 taken 59 times.
✓ Branch 5 taken 100 times.
17781 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6540 {
6541
1/2
✓ Branch 0 taken 16164 times.
✗ Branch 1 not taken.
16164 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6542 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6543 16164 itemid = vbound(itemid, 0, MAXITEMS-1);
6544
6545
2/2
✓ Branch 0 taken 16160 times.
✓ Branch 1 taken 1039 times.
17199 for(int32_t j=0; j<Ewpns.Count(); j++)
6546 {
6547 1039 sprite *t = Ewpns.spr(j);
6548
6549
2/2
✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 4 times.
1039 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6550 {
6551 4 bool reflect = false;
6552 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6553
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
4 switch(t->id)
6554 {
6555 case ewBrang:
6556 if(!(itemsbuf[itemid].misc3 & shBRANG)) break;
6557
6558 reflect = ((itemsbuf[itemid].misc4 & shBRANG) != 0);
6559 goto killweapon;
6560
6561 case ewArrow:
6562 if(!(itemsbuf[itemid].misc3 & shARROW)) break;
6563
6564 reflect = ((itemsbuf[itemid].misc4 & shARROW) != 0);
6565 goto killweapon;
6566
6567 case ewRock:
6568 if(!(itemsbuf[itemid].misc3 & shROCK)) break;
6569
6570 reflect = ((itemsbuf[itemid].misc4 & shROCK) != 0);
6571 goto killweapon;
6572
6573 case ewFireball2:
6574 case ewFireball:
6575 {
6576 int32_t mask = (((weapon*)t)->type&1 ? shFIREBALL2 : shFIREBALL);
6577
6578 if(!(itemsbuf[itemid].misc3 & mask)) break;
6579
6580 reflect = ((itemsbuf[itemid].misc4 & mask) != 0);
6581 goto killweapon;
6582 }
6583
6584 case ewSword:
6585 if(!(itemsbuf[itemid].misc3 & shSWORD)) break;
6586
6587 reflect = ((itemsbuf[itemid].misc4 & shSWORD) != 0);
6588 goto killweapon;
6589
6590 case wRefMagic:
6591 case ewMagic:
6592 if(!(itemsbuf[itemid].misc3 & shMAGIC)) break;
6593
6594 reflect = ((itemsbuf[itemid].misc4 & shMAGIC) != 0);
6595 goto killweapon;
6596
6597 case wScript1:
6598 case wScript2:
6599 case wScript3:
6600 case wScript4:
6601 case wScript5:
6602 case wScript6:
6603 case wScript7:
6604 case wScript8:
6605 case wScript9:
6606 case wScript10:
6607 if(!(itemsbuf[itemid].misc3 & shSCRIPT)) break;
6608
6609 reflect = ((itemsbuf[itemid].misc4 & shSCRIPT) != 0);
6610 goto killweapon;
6611
6612 case ewLitBomb:
6613 case ewLitSBomb:
6614 killweapon:
6615 ((weapon*)s)->dead=1;
6616 weapon *ew = ((weapon*)t);
6617 int32_t oldid = ew->id;
6618 ew->onhit(true, reflect ? 2 : 1, s->dir);
6619
6620 if(ew->id != oldid || (ew->id>=wScript1 && ew->id<=wScript10)) // changed type from ewX to wX... Except for script weapons
6621 {
6622 Lwpns.add(ew);
6623 Ewpns.remove(ew);
6624 ew->isLWeapon = true; //Make sure this gets set everywhere!
6625 }
6626
6627 if(ew->id==wRefMagic)
6628 {
6629 ew->ignoreHero=true;
6630 ew->ignorecombo=-1;
6631 }
6632
6633 break;
6634 }
6635
6636 4 break;
6637 }
6638 1035 }
6639 16164 }
6640 17781 }
6641
6642
6/6
✓ Branch 0 taken 1547457 times.
✓ Branch 1 taken 700135 times.
✓ Branch 2 taken 374601 times.
✓ Branch 3 taken 1172856 times.
✓ Branch 4 taken 29754 times.
✓ Branch 5 taken 344847 times.
2247592 if((itemsbuf[itemid].flags & ITEM_FLAG2)||(itemid==-1&&get_bit(quest_rules,qr_OUCHBOMBS)))
6643 {
6644
7/10
✓ Branch 0 taken 726143 times.
✓ Branch 1 taken 3746 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 729885 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 4 times.
729889 if(((s->id==wBomb)||(s->id==wSBomb)) && s->hit(this) && !superman && (scriptcoldet&1) && !fallclk)
6645 {
6646 4 std::vector<int32_t> &ev = FFCore.eventData;
6647 4 ev.clear();
6648
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 ev.push_back(((((weapon*)s)->parentitem>-1 ? itemsbuf[((weapon*)s)->parentitem].misc3 : ((weapon*)s)->power) *game->get_hp_per_heart())*10000);
6649 4 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6650 4 ev.push_back(0);
6651 4 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6652 4 ev.push_back(48*10000);
6653 4 ev.push_back(ZSD_LWPN*10000);
6654 4 ev.push_back(s->getUID());
6655
6656 4 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6657 4 int32_t dmg = ev[0]/10000;
6658 4 bool nullhit = ev[2] != 0;
6659
6660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(nullhit) {ev.clear(); return;}
6661
6662 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6663 4 ev[0] = ringpower(dmg)*10000;
6664
6665 4 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6666 4 dmg = ev[0]/10000;
6667 4 int32_t hdir = ev[1]/10000;
6668 4 nullhit = ev[2] != 0;
6669 4 bool nayrulove = ev[3] != 0;
6670 4 int32_t iframes = ev[4] / 10000;
6671 4 ev.clear();
6672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(nullhit) return;
6673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!nayrulove)
6674 {
6675
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6676 4 }
6677
6678 4 hitdir = hdir;
6679
6680
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 if (action != rafting && action != freeze && action != sideswimfreeze)
6681 {
6682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (IsSideSwim())
6683 {
6684 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6685 }
6686
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 else if (action == swimming || hopclk == 0xFF)
6687 {
6688 action=swimhit; FFCore.setHeroAction(swimhit);
6689 }
6690 else
6691 {
6692 4 action=gothit; FFCore.setHeroAction(gothit);
6693 }
6694 4 }
6695
6696
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
4 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6697 {
6698 spins = charging = attackclk = 0;
6699 attack=none;
6700 tapping = false;
6701 }
6702
6703 4 hclk=iframes;
6704 4 sfx(getHurtSFX(),pan(x.getInt()));
6705 4 return;
6706 }
6707 729885 }
6708
6709
7/8
✓ Branch 0 taken 2247588 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4604 times.
✓ Branch 3 taken 2242984 times.
✓ Branch 4 taken 4565 times.
✓ Branch 5 taken 39 times.
✓ Branch 6 taken 2247549 times.
✓ Branch 7 taken 39 times.
2247588 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6710 {
6711 39 std::vector<int32_t> &ev = FFCore.eventData;
6712 39 ev.clear();
6713 39 ev.push_back(0);
6714 39 ev.push_back(s->dir*10000);
6715 39 ev.push_back(0);
6716 39 ev.push_back(0);
6717 39 ev.push_back(ZSD_LWPN*10000);
6718 39 ev.push_back(s->getUID());
6719
6720 39 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6721 39 bool nullhit = ev[2] != 0;
6722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(nullhit) {ev.clear(); return;}
6723
6724 39 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6725 39 int32_t hdir = ev[1]/10000;
6726 39 nullhit = ev[2] != 0;
6727 39 ev.clear();
6728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(nullhit) return;
6729
6730 39 reset_hookshot();
6731 39 xofs=1000;
6732 39 action=inwind; FFCore.setHeroAction(inwind);
6733 39 dir=s->dir=hdir;
6734 39 spins = charging = attackclk = 0;
6735
6736 // In case Hero used two whistles in a row, summoning two whirlwinds,
6737 // check which whistle's whirlwind picked him up so the correct
6738 // warp ring will be used
6739 39 int32_t whistle=((weapon*)s)->parentitem;
6740
6741
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
39 if(whistle>-1 && itemsbuf[whistle].family==itype_whistle)
6742 39 whistleitem=whistle;
6743
6744 39 return;
6745 }
6746 2247549 }
6747
6748
6/8
✓ Branch 0 taken 4816490 times.
✓ Branch 1 taken 60412 times.
✓ Branch 2 taken 4754155 times.
✓ Branch 3 taken 62335 times.
✓ Branch 4 taken 4754155 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4754155 times.
9631057 if(action==rafting || action==freeze || action==sideswimfreeze ||
6749
4/8
✓ Branch 0 taken 4754155 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4754155 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4754155 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4754155 times.
✗ Branch 7 not taken.
4754155 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6750 122747 return;
6751
6752 4754155 int32_t hit2 = -1;
6753 4754155 do
6754 {
6755
2/2
✓ Branch 0 taken 634325 times.
✓ Branch 1 taken 4123612 times.
4757937 hit2 = diagonalMovement ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6756 4123612 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6757
6758
2/2
✓ Branch 0 taken 4746877 times.
✓ Branch 1 taken 11060 times.
4757937 if(hit2!=-1)
6759 {
6760
2/2
✓ Branch 0 taken 3782 times.
✓ Branch 1 taken 7278 times.
11060 if (hithero(hit2) == 0) return;
6761 3782 }
6762
2/2
✓ Branch 0 taken 3782 times.
✓ Branch 1 taken 4746877 times.
4750659 } while (hit2 != -1);
6763
6/6
✓ Branch 0 taken 4630569 times.
✓ Branch 1 taken 116308 times.
✓ Branch 2 taken 4618533 times.
✓ Branch 3 taken 12036 times.
✓ Branch 4 taken 173 times.
✓ Branch 5 taken 4618360 times.
4746877 if (superman || !(scriptcoldet&1) || fallclk) return;
6764 4618360 hit2 = LwpnHit();
6765
6766
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4618358 times.
4618360 if(hit2!=-1)
6767 {
6768 2 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
6769 2 std::vector<int32_t> &ev = FFCore.eventData;
6770 2 ev.clear();
6771 2 ev.push_back((lwpn_dp(hit2)*10000));
6772 2 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
6773 2 ev.push_back(0);
6774 2 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6775 2 ev.push_back(48*10000);
6776 2 ev.push_back(ZSD_LWPN*10000);
6777 2 ev.push_back(lwpnspr->getUID());
6778
6779 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6780 2 int32_t dmg = ev[0]/10000;
6781 2 bool nullhit = ev[2] != 0;
6782
6783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) {ev.clear(); return;}
6784
6785 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6786 2 ev[0] = ringpower(dmg)*10000;
6787
6788 2 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6789 2 dmg = ev[0]/10000;
6790 2 int32_t hdir = ev[1]/10000;
6791 2 nullhit = ev[2] != 0;
6792 2 bool nayrulove = ev[3] != 0;
6793 2 int32_t iframes = ev[4] / 10000;
6794 2 ev.clear();
6795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(nullhit) return;
6796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!nayrulove)
6797 {
6798
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 game->set_life(zc_max(game->get_life()-dmg,0));
6799 2 sethitHeroUID(HIT_BY_LWEAPON,(hit2+1));
6800 2 sethitHeroUID(HIT_BY_LWEAPON_UID,lwpnspr->getUID());
6801 2 }
6802
6803 2 hitdir = hdir;
6804 2 lwpnspr->onhit(false);
6805
6806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (IsSideSwim())
6807 {
6808 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6809 }
6810
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 else if(action==swimming || hopclk==0xFF)
6811 {
6812 action=swimhit; FFCore.setHeroAction(swimhit);
6813 }
6814 else
6815 {
6816 2 action=gothit; FFCore.setHeroAction(gothit);
6817 }
6818
6819 2 hclk=iframes;
6820
6821
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
2 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6822 {
6823 spins = charging = attackclk = 0;
6824 attack=none;
6825 tapping = false;
6826 }
6827
6828 2 sfx(getHurtSFX(),pan(x.getInt()));
6829 2 return;
6830 }
6831
6832 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
6833
6834 4618358 hit2 = EwpnHit();
6835
6836
2/2
✓ Branch 0 taken 2479 times.
✓ Branch 1 taken 4615879 times.
4618358 if(hit2!=-1)
6837 {
6838 2479 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
6839 2479 std::vector<int32_t> &ev = FFCore.eventData;
6840 2479 ev.clear();
6841 2479 ev.push_back((ewpn_dp(hit2)*10000));
6842 2479 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
6843 2479 ev.push_back(0);
6844 2479 ev.push_back(NayrusLoveShieldClk>0?10000:0);
6845 2479 ev.push_back(48*10000);
6846 2479 ev.push_back(ZSD_EWPN*10000);
6847 2479 ev.push_back(ewpnspr->getUID());
6848
6849 2479 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6850 2479 int32_t dmg = ev[0]/10000;
6851 2479 bool nullhit = ev[2] != 0;
6852
6853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2479 times.
2479 if(nullhit) {ev.clear(); return;}
6854
6855 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6856 2479 ev[0] = ringpower(dmg)*10000;
6857
6858 2479 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6859 2479 dmg = ev[0]/10000;
6860 2479 int32_t hdir = ev[1]/10000;
6861 2479 nullhit = ev[2] != 0;
6862 2479 bool nayrulove = ev[3] != 0;
6863 2479 int32_t iframes = ev[4] / 10000;
6864 2479 ev.clear();
6865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2479 times.
2479 if(nullhit) return;
6866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2479 times.
2479 if(!nayrulove)
6867 {
6868
2/2
✓ Branch 0 taken 2468 times.
✓ Branch 1 taken 11 times.
2479 game->set_life(zc_max(game->get_life()-dmg,0));
6869 2479 sethitHeroUID(HIT_BY_EWEAPON,(hit2+1));
6870 2479 sethitHeroUID(HIT_BY_EWEAPON_UID,ewpnspr->getUID());
6871 2479 }
6872
6873 2479 hitdir = hdir;
6874 2479 ewpnspr->onhit(false);
6875
6876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2479 times.
2479 if (IsSideSwim())
6877 {
6878 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6879 }
6880
3/4
✓ Branch 0 taken 2453 times.
✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2453 times.
2479 else if(action==swimming || hopclk==0xFF)
6881 {
6882 26 action=swimhit; FFCore.setHeroAction(swimhit);
6883 26 }
6884 else
6885 {
6886 2453 action=gothit; FFCore.setHeroAction(gothit);
6887 }
6888
6889 2479 hclk=iframes;
6890
6891
6/8
✓ Branch 0 taken 2476 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2476 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 773 times.
✓ Branch 5 taken 1703 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 773 times.
2479 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6892 {
6893 1706 spins = charging = attackclk = 0;
6894 1706 attack=none;
6895 1706 tapping = false;
6896 1706 }
6897
6898 2479 sfx(getHurtSFX(),pan(x.getInt()));
6899 2479 return;
6900 }
6901 //else { sethitHeroUID(HIT_BY_EWEAPON,(0)); } //fails to clear
6902
6903 // The rest of this method deals with damage combos, which can be jumped over.
6904
4/4
✓ Branch 0 taken 4612611 times.
✓ Branch 1 taken 3268 times.
✓ Branch 2 taken 4612611 times.
✓ Branch 3 taken 3268 times.
4615879 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) return;
6905
6906 4612611 int32_t dx1 = (int32_t)x+8-(tmpscr->csensitive);
6907 4612611 int32_t dx2 = (int32_t)x+8+(tmpscr->csensitive-1);
6908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4612611 times.
4612611 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?tmpscr->csensitive:(tmpscr->csensitive+1)/2);
6909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4612611 times.
4612611 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?tmpscr->csensitive-1:((tmpscr->csensitive+1)/2)-1);
6910
6911
2/2
✓ Branch 0 taken 4612611 times.
✓ Branch 1 taken 8430091 times.
13042702 for(int32_t i=get_bit(quest_rules, qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
6912 8430091 (void)checkdamagecombos(dx1,dx2,dy1,dy2,i);
6913 5152513 }
6914
6915 3201 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
6916 {
6917 3201 return checkdamagecombos(dx,dx,dy,dy);
6918 }
6919
6920 107 void HeroClass::doHit(int32_t hdir)
6921 {
6922 107 hitdir = hdir;
6923
6924
3/6
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 107 times.
107 if (action != rafting && action != freeze && action != sideswimfreeze)
6925 {
6926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
107 if (IsSideSwim())
6927 {
6928 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
6929 }
6930
2/4
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 107 times.
107 else if (action == swimming || hopclk == 0xFF)
6931 {
6932 action=swimhit; FFCore.setHeroAction(swimhit);
6933 }
6934 else
6935 {
6936 107 action=gothit; FFCore.setHeroAction(gothit);
6937 }
6938 107 }
6939
6940 107 hclk=48;
6941
6942
5/8
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✓ Branch 5 taken 39 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 68 times.
107 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
6943 {
6944 39 spins = charging = attackclk = 0;
6945 39 attack=none;
6946 39 tapping = false;
6947 39 }
6948
6949 107 sfx(getHurtSFX(),pan(x.getInt()));
6950 107 }
6951
6952 9279202 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
6953 {
6954
5/6
✓ Branch 0 taken 9279189 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 9274305 times.
✓ Branch 3 taken 4884 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9274305 times.
9279202 if(hclk || superman || fallclk)
6955 4897 return false;
6956
6957 9274305 int32_t hp_mod[4] = {0};
6958 int32_t cid[8];
6959 9274305 byte hasKB = 0;
6960
6961 {
6962
2/2
✓ Branch 0 taken 4378091 times.
✓ Branch 1 taken 4896214 times.
9274305 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
6963 9274305 newcombo& cmb = combobuf[cid[0]];
6964
4/4
✓ Branch 0 taken 9274302 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 9274225 times.
✓ Branch 3 taken 77 times.
9274305 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6965 {
6966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(cmb.usrflags&cflag1)
6967 hp_mod[0] = cmb.attributes[0] / -10000L;
6968 else
6969 77 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
6970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(!(cmb.usrflags&cflag2))
6971 77 hasKB |= 1<<0;
6972 77 }
6973 }
6974 {
6975
2/2
✓ Branch 0 taken 4378091 times.
✓ Branch 1 taken 4896214 times.
9274305 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
6976 9274305 newcombo& cmb = combobuf[cid[1]];
6977
4/4
✓ Branch 0 taken 9274302 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 9274207 times.
✓ Branch 3 taken 95 times.
9274305 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6978 {
6979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(cmb.usrflags&cflag1)
6980 hp_mod[1] = cmb.attributes[0] / -10000L;
6981 else
6982 95 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
6983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(!(cmb.usrflags&cflag2))
6984 95 hasKB |= 1<<1;
6985 95 }
6986 }
6987 {
6988
2/2
✓ Branch 0 taken 4378091 times.
✓ Branch 1 taken 4896214 times.
9274305 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
6989 9274305 newcombo& cmb = combobuf[cid[2]];
6990
4/4
✓ Branch 0 taken 9274302 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 9274218 times.
✓ Branch 3 taken 84 times.
9274305 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
6991 {
6992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(cmb.usrflags&cflag1)
6993 hp_mod[2] = cmb.attributes[0] / -10000L;
6994 else
6995 84 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
6996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(!(cmb.usrflags&cflag2))
6997 84 hasKB |= 1<<2;
6998 84 }
6999 }
7000 {
7001
2/2
✓ Branch 0 taken 4378091 times.
✓ Branch 1 taken 4896214 times.
9274305 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
7002 9274305 newcombo& cmb = combobuf[cid[3]];
7003
4/4
✓ Branch 0 taken 9274302 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 9274203 times.
✓ Branch 3 taken 99 times.
9274305 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7004 {
7005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(cmb.usrflags&cflag1)
7006 hp_mod[3] = cmb.attributes[0] / -10000L;
7007 else
7008 99 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(!(cmb.usrflags&cflag2))
7010 99 hasKB |= 1<<3;
7011 99 }
7012 }
7013
7014 9274305 int32_t bestcid=0;
7015 9274305 int32_t hp_modtotal=0;
7016
2/2
✓ Branch 0 taken 6495926 times.
✓ Branch 1 taken 2778379 times.
9274305 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7017
2/2
✓ Branch 0 taken 6492019 times.
✓ Branch 1 taken 2782286 times.
9274305 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7018
2/2
✓ Branch 0 taken 6495958 times.
✓ Branch 1 taken 2778347 times.
9274305 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7019
2/2
✓ Branch 0 taken 6492052 times.
✓ Branch 1 taken 2782253 times.
9274305 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7020
7021
2/2
✓ Branch 0 taken 18548610 times.
✓ Branch 1 taken 9274305 times.
27822915 for (int32_t i = 0; i <= 1; ++i)
7022 {
7023
2/2
✓ Branch 0 taken 13391714 times.
✓ Branch 1 taken 5156896 times.
18548610 if(tmpscr2[i].valid!=0)
7024 {
7025
2/2
✓ Branch 0 taken 4777621 times.
✓ Branch 1 taken 379275 times.
5156896 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
7026 {
7027
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4777621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4777621 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7028
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4777621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4777621 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7029
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4777621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4777621 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7030
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4777621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4777621 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7031 4777621 }
7032 else
7033 {
7034
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 378924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
379275 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7035
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 378924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
379275 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7036
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 378924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
379275 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7037
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 378924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
379275 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7038 }
7039 5156896 }
7040 18548610 }
7041
7042
2/2
✓ Branch 0 taken 37097220 times.
✓ Branch 1 taken 9274305 times.
46371525 for(int32_t i=0; i<4; i++)
7043 {
7044
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 21572828 times.
37097220 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7045 {
7046
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
7047 {
7048
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotal)
7049 {
7050 63 hp_modtotal = hp_mod[i];
7051 63 bestcid = cid[i];
7052 63 }
7053 15524232 }
7054
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
7055 {
7056
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotal)
7057 {
7058 hp_modtotal = hp_mod[i];
7059 bestcid = cid[i];
7060 }
7061 139 }
7062 15524392 }
7063
2/2
✓ Branch 0 taken 21572780 times.
✓ Branch 1 taken 48 times.
21572828 else if(hp_mod[i] < hp_modtotal)
7064 {
7065 48 hp_modtotal = hp_mod[i];
7066 48 bestcid = cid[i];
7067 48 }
7068 37097220 }
7069
7070 {
7071 9274305 cid[4] = MAPFFCOMBO(dx1,dy1);
7072 9274305 newcombo& cmb = combobuf[cid[4]];
7073
4/4
✓ Branch 0 taken 9274110 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 9273760 times.
✓ Branch 3 taken 350 times.
9274305 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7074 {
7075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if(cmb.usrflags&cflag1 )
7076 hp_mod[0] = cmb.attributes[0]/10000L;
7077 else
7078 350 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7079
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(!(cmb.usrflags&cflag2))
7080 hasKB |= 1<<4;
7081 350 }
7082 }
7083 {
7084 9274305 cid[5] = MAPFFCOMBO(dx1,dy2);
7085 9274305 newcombo& cmb = combobuf[cid[5]];
7086
4/4
✓ Branch 0 taken 9274101 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 9273760 times.
✓ Branch 3 taken 341 times.
9274305 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7087 {
7088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
341 if(cmb.usrflags&cflag1 )
7089 hp_mod[1] = cmb.attributes[0]/10000L;
7090 else
7091 341 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7092
1/2
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
341 if(!(cmb.usrflags&cflag2))
7093 hasKB |= 1<<5;
7094 341 }
7095 }
7096 {
7097 9274305 cid[6] = MAPFFCOMBO(dx2,dy1);
7098 9274305 newcombo& cmb = combobuf[cid[6]];
7099
4/4
✓ Branch 0 taken 9274113 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 9273751 times.
✓ Branch 3 taken 362 times.
9274305 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7100 {
7101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
362 if(cmb.usrflags&cflag1 )
7102 hp_mod[2] = cmb.attributes[0]/10000L;
7103 else
7104 362 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7105
1/2
✓ Branch 0 taken 362 times.
✗ Branch 1 not taken.
362 if(!(cmb.usrflags&cflag2))
7106 hasKB |= 1<<6;
7107 362 }
7108 }
7109 {
7110 9274305 cid[7] = MAPFFCOMBO(dx2,dy2);
7111 9274305 newcombo& cmb = combobuf[cid[7]];
7112
4/4
✓ Branch 0 taken 9274104 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 9273763 times.
✓ Branch 3 taken 341 times.
9274305 if ( !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && combo_class_buf[cmb.type].modify_hp_amount)
7113 {
7114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
341 if(cmb.usrflags&cflag1 )
7115 hp_mod[3] = cmb.attributes[0]/10000L;
7116 else
7117 341 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7118
1/2
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
341 if(!(cmb.usrflags&cflag2))
7119 hasKB |= 1<<7;
7120 341 }
7121 }
7122
7123 9274305 int32_t bestffccid = 0;
7124 9274305 int32_t hp_modtotalffc = 0;
7125
7126
2/2
✓ Branch 0 taken 18548610 times.
✓ Branch 1 taken 9274305 times.
27822915 for (int32_t i = 0; i <= 1; ++i)
7127 {
7128
2/2
✓ Branch 0 taken 13391714 times.
✓ Branch 1 taken 5156896 times.
18548610 if(tmpscr2[i].valid!=0)
7129 {
7130
2/2
✓ Branch 0 taken 4777621 times.
✓ Branch 1 taken 379275 times.
5156896 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
7131 {
7132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4777621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4777621 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7133
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4777621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4777621 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4777621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4777621 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4777621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4777621 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7136 4777621 }
7137 else
7138 {
7139
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 378924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
379275 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,1, &(tmpscr2[i]))) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7140
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 378924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
379275 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,1, &(tmpscr2[i]))) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7141
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 378924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
379275 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,1, &(tmpscr2[i]))) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7142
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 378924 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
379275 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,1, &(tmpscr2[i]))) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7143 }
7144 5156896 }
7145 18548610 }
7146
7147
2/2
✓ Branch 0 taken 37097220 times.
✓ Branch 1 taken 9274305 times.
46371525 for(int32_t i=0; i<4; i++)
7148 {
7149
2/2
✓ Branch 0 taken 15524392 times.
✓ Branch 1 taken 21572828 times.
37097220 if(get_bit(quest_rules,qr_DMGCOMBOPRI))
7150 {
7151
2/2
✓ Branch 0 taken 15524232 times.
✓ Branch 1 taken 160 times.
15524392 if(hp_modtotalffc >= 0)
7152 {
7153
2/2
✓ Branch 0 taken 15524169 times.
✓ Branch 1 taken 63 times.
15524232 if(hp_mod[i] < hp_modtotalffc)
7154 {
7155 63 hp_modtotalffc = hp_mod[i];
7156 63 bestffccid = cid[4+i];
7157 63 }
7158 15524232 }
7159
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 139 times.
160 else if(hp_mod[i] < 0)
7160 {
7161
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(hp_mod[i] > hp_modtotalffc)
7162 {
7163 hp_modtotalffc = hp_mod[i];
7164 bestffccid = cid[4+i];
7165 }
7166 139 }
7167 15524392 }
7168
2/2
✓ Branch 0 taken 21572397 times.
✓ Branch 1 taken 431 times.
21572828 else if(hp_mod[i] < hp_modtotalffc)
7169 {
7170 431 hp_modtotalffc = hp_mod[i];
7171 431 bestffccid = cid[4+i];
7172 431 }
7173 37097220 }
7174
7175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9274305 times.
9274305 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7176
1/2
✓ Branch 0 taken 9274305 times.
✗ Branch 1 not taken.
9274305 if(hp_modtotalffc < hp_modmin) bestcid = bestffccid;
7177
7178 9274305 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & ITEM_FLAG1));
7179 9274305 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & ITEM_FLAG1));
7180 9274305 bool current_ring = ((tmpscr->flags6&fTOGGLERINGDAMAGE) != 0);
7181
1/2
✓ Branch 0 taken 9274305 times.
✗ Branch 1 not taken.
9274305 if(current_ring)
7182 {
7183 global_defring = !global_defring;
7184 global_perilring = !global_perilring;
7185 }
7186 9274305 int32_t itemid = current_item_id(itype_boots);
7187
7188
2/2
✓ Branch 0 taken 8859770 times.
✓ Branch 1 taken 414535 times.
9274305 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & ITEM_FLAG1);
7189
2/2
✓ Branch 0 taken 8859770 times.
✓ Branch 1 taken 414535 times.
9274305 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & ITEM_FLAG3);
7190
7191
2/2
✓ Branch 0 taken 9273811 times.
✓ Branch 1 taken 494 times.
9274305 if(hp_modmin<0)
7192 {
7193
8/14
✓ Branch 0 taken 374 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 374 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 374 times.
✓ Branch 10 taken 374 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 374 times.
494 if((itemid<0) || ignoreBoots || (tmpscr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7194 {
7195
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 14 times.
120 if (!do_health_check) return true;
7196 106 std::vector<int32_t> &ev = FFCore.eventData;
7197 106 ev.clear();
7198 106 ev.push_back(-hp_modmin*10000);
7199
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 3 times.
106 ev.push_back((hasKB ? dir^1 : -1)*10000);
7200 106 ev.push_back(0);
7201 106 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7202 106 ev.push_back(48*10000);
7203 106 ev.push_back(ZSD_COMBODATA*10000);
7204 106 ev.push_back(bestcid);
7205
7206 106 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7207 106 int32_t dmg = ev[0]/10000;
7208 106 bool nullhit = ev[2] != 0;
7209
7210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(nullhit) {ev.clear(); return false;}
7211
7212 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7213 106 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7214
7215 106 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7216 106 dmg = ev[0]/10000;
7217 106 int32_t hdir = ev[1]/10000;
7218 106 nullhit = ev[2] != 0;
7219 106 bool nayrulove = ev[3] != 0;
7220 106 int32_t iframes = ev[4] / 10000;
7221 106 ev.clear();
7222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(nullhit) return false;
7223
7224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(!nayrulove)
7225 {
7226
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 3 times.
106 game->set_life(zc_max(game->get_life()-dmg,0));
7227 106 }
7228
7229 106 hitdir = hdir;
7230 106 doHit(hitdir);
7231 106 hclk = iframes;
7232 106 return true;
7233 }
7234
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 50 times.
374 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7235 374 }
7236
7237 9274185 return false;
7238 9279202 }
7239
7240 11126 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7241 {
7242
1/2
✓ Branch 0 taken 11126 times.
✗ Branch 1 not taken.
11126 if(force_hdir > 3) force_hdir = -1;
7243 11126 enemy* enemyptr = (enemy*)guys.spr(hit2);
7244
1/2
✓ Branch 0 taken 11126 times.
✗ Branch 1 not taken.
11126 if(!enemyptr) return 0;
7245 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7246 11126 int32_t stompid = current_item_id(itype_stompboots);
7247
5/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 11111 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11126 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7248
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7249
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7250 {
7251 paymagiccost(stompid);
7252 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7253
7254 if(itemsbuf[stompid].flags & ITEM_FLAG1)
7255 {
7256 fall = -(itemsbuf[stompid].misc1);
7257 }
7258
7259 if(itemsbuf[stompid].flags & ITEM_DOWNGRADE)
7260 game->set_item(stompid,false);
7261
7262 // Stomp Boots script
7263 if(itemsbuf[stompid].script != 0 && !(item_doscript[stompid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
7264 {
7265 //clear the item script stack for a new script
7266 ri = &(itemScriptData[stompid]);
7267 for ( int32_t q = 0; q < 1024; q++ ) item_stack[stompid][q] = 0xFFFF;
7268 ri->Clear();
7269 //itemScriptData[(stompid & 0xFFF)].Clear();
7270 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(stompid & 0xFFF)][q] = 0;
7271 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid & 0xFFF);
7272 item_doscript[stompid] = 1;
7273 itemscriptInitialised[stompid] = 0;
7274 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[stompid].script, stompid);
7275 }
7276
7277 return -1;
7278 }
7279
5/6
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 3315 times.
✓ Branch 2 taken 6858 times.
✓ Branch 3 taken 953 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6858 times.
11126 else if(superman || !(scriptcoldet&1) || fallclk)
7280 4268 return 0;
7281 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7282 //!Add a flag check to this if:
7283
5/6
✓ Branch 0 taken 3298 times.
✓ Branch 1 taken 3560 times.
✓ Branch 2 taken 3298 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1784 times.
✓ Branch 5 taken 1514 times.
6858 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7284
3/4
✓ Branch 0 taken 1541 times.
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3055 times.
3298 && (enemyptr->d->family != eeGUY || enemyptr->dmisc1)))
7285 {
7286 3803 return -1;
7287 }
7288
7289 3055 std::vector<int32_t> &ev = FFCore.eventData;
7290 3055 ev.clear();
7291 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7292 3055 ev.push_back((enemy_dp(hit2) *10000));
7293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3055 times.
3055 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7294 3055 ev.push_back(0);
7295 3055 ev.push_back(NayrusLoveShieldClk>0?10000:0);
7296 3055 ev.push_back(48*10000);
7297 3055 ev.push_back(ZSD_NPC*10000);
7298 3055 ev.push_back(enemyptr->getUID());
7299
7300 3055 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7301 3055 int32_t dmg = ev[0] / 10000;
7302 3055 bool nullhit = ev[2] != 0;
7303
7304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3055 times.
3055 if(nullhit) {ev.clear(); return -1;}
7305
7306 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7307 3055 ev[0] = ((ringpower(dmg)*10000));
7308
7309 3055 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7310 3055 dmg = ev[0] / 10000;
7311 3055 int32_t hdir = ev[1] / 10000;
7312 3055 nullhit = ev[2] != 0;
7313 3055 bool nayrulove = ev[3] != 0;
7314 3055 int32_t iframes = ev[4] / 10000;
7315 3055 ev.clear();
7316
7317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3055 times.
3055 if(nullhit) return -1;
7318
7319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3055 times.
3055 if(!nayrulove)
7320 {
7321
2/2
✓ Branch 0 taken 3035 times.
✓ Branch 1 taken 20 times.
3055 game->set_life(zc_max(game->get_life()-dmg,0));
7322 3055 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7323 3055 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7324 3055 }
7325
7326 3055 hitdir = hdir;
7327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3055 times.
3055 if (IsSideSwim())
7328 {
7329 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7330 }
7331
3/4
✓ Branch 0 taken 3027 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3027 times.
3055 else if(action==swimming || hopclk==0xFF)
7332 {
7333 28 action=swimhit; FFCore.setHeroAction(swimhit);
7334 28 }
7335 else
7336 {
7337 3027 action=gothit; FFCore.setHeroAction(gothit);
7338 }
7339
7340 3055 hclk=iframes;
7341 3055 sfx(getHurtSFX(),pan(x.getInt()));
7342
7343
7/8
✓ Branch 0 taken 3053 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3053 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1105 times.
✓ Branch 5 taken 1948 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 1096 times.
3055 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7344 {
7345 1959 spins = charging = attackclk = 0;
7346 1959 attack=none;
7347 1959 tapping = false;
7348 1959 }
7349
7350 3055 enemy_scored(hit2);
7351 3055 int32_t dm7 = enemyptr->dmisc7;
7352 3055 int32_t dm8 = enemyptr->dmisc8;
7353
7354
3/3
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1608 times.
3055 switch(enemyptr->family)
7355 {
7356 case eeWALLM:
7357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(enemyptr->hp>0)
7358 {
7359 3 GrabHero(hit2);
7360 3 inwallm=true;
7361 3 action=none; FFCore.setHeroAction(none);
7362 3 }
7363 3 break;
7364
7365 //case eBUBBLEST:
7366 //case eeBUBBLE:
7367 case eeWALK:
7368 {
7369 1608 int32_t itemid = current_item_id(itype_whispring);
7370 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7371
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
1608 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7372
3/4
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 1448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
1608 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7373
7374
5/7
✓ Branch 0 taken 1230 times.
✓ Branch 1 taken 236 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 69 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21 times.
✗ Branch 6 not taken.
1608 switch(dm7)
7375 {
7376 case e7tTEMPJINX:
7377
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
236 if(dm8==0 || dm8==2)
7378
4/4
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 213 times.
430 if(swordclk>=0 && !(sworddivisor==0))
7379 213 swordclk=150;
7380
7381
3/4
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 217 times.
236 if(dm8==1 || dm8==2)
7382
3/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 18 times.
37 if(itemclk>=0 && !(itemdivisor==0))
7383 18 itemclk=150;
7384
7385 236 break;
7386
7387 case e7tPERMJINX:
7388
3/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
52 if(dm8==0 || dm8==2)
7389
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
36 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/sworddivisor) : -1;
7390
7391
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
52 if(dm8==1 || dm8==2)
7392
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
16 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & ITEM_FLAG1)? int32_t(150/itemdivisor) : -1;
7393
7394 52 break;
7395
7396 case e7tUNJINX:
7397
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
69 if(dm8==0 || dm8==2)
7398 57 swordclk=0;
7399
7400
3/4
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
69 if(dm8==1 || dm8==2)
7401 12 itemclk=0;
7402
7403 69 break;
7404
7405 case e7tTAKEMAGIC:
7406 game->change_dmagic(-dm8*game->get_magicdrainrate());
7407 break;
7408
7409 case e7tTAKERUPEES:
7410 21 game->change_drupy(-dm8);
7411 21 break;
7412
7413 case e7tDRUNK:
7414 drunkclk += dm8;
7415 break;
7416 }
7417 1608 verifyAWpn();
7418
2/2
✓ Branch 0 taken 1561 times.
✓ Branch 1 taken 47 times.
1608 if(dm7 >= e7tEATITEMS)
7419 {
7420 47 EatHero(hit2);
7421 47 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7422 47 action=none; FFCore.setHeroAction(none);
7423 47 }
7424 }
7425 1608 }
7426 3055 return 0;
7427 11126 }
7428
7429 267854 void HeroClass::addsparkle(int32_t wpn)
7430 {
7431 //return;
7432 267854 weapon *w = (weapon*)Lwpns.spr(wpn);
7433 267854 int32_t itemid = w->parentitem;
7434
7435
2/2
✓ Branch 0 taken 266326 times.
✓ Branch 1 taken 1528 times.
267854 if(itemid<0)
7436 1528 return;
7437
7438 266326 int32_t itemtype = itemsbuf[itemid].family;
7439
7440
4/4
✓ Branch 0 taken 266253 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 66543 times.
✓ Branch 3 taken 199710 times.
266326 if(itemtype!=itype_cbyrna && frame%4)
7441 199710 return;
7442
7443
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 66543 times.
66616 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7444
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 66543 times.
66616 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7445 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7446
5/8
✓ Branch 0 taken 21221 times.
✓ Branch 1 taken 45395 times.
✓ Branch 2 taken 30677 times.
✓ Branch 3 taken 14718 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21221 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
66616 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7447 66616 int32_t direction=w->dir;
7448
7449
2/2
✓ Branch 0 taken 30677 times.
✓ Branch 1 taken 35939 times.
66616 if(sparkle_type)
7450 {
7451 35939 int32_t h=0;
7452 35939 int32_t v=0;
7453
7454
6/6
✓ Branch 0 taken 28702 times.
✓ Branch 1 taken 7237 times.
✓ Branch 2 taken 25522 times.
✓ Branch 3 taken 3180 times.
✓ Branch 4 taken 5618 times.
✓ Branch 5 taken 19904 times.
35939 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7455 {
7456 16035 h=-1;
7457 16035 }
7458
7459
6/6
✓ Branch 0 taken 29061 times.
✓ Branch 1 taken 6878 times.
✓ Branch 2 taken 24309 times.
✓ Branch 3 taken 4752 times.
✓ Branch 4 taken 3635 times.
✓ Branch 5 taken 20674 times.
35939 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7460 {
7461 15265 h=1;
7462 15265 }
7463
7464
6/6
✓ Branch 0 taken 33939 times.
✓ Branch 1 taken 2000 times.
✓ Branch 2 taken 30304 times.
✓ Branch 3 taken 3635 times.
✓ Branch 4 taken 5618 times.
✓ Branch 5 taken 24686 times.
35939 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7465 {
7466 11253 v=-1;
7467 11253 }
7468
7469
6/6
✓ Branch 0 taken 33300 times.
✓ Branch 1 taken 2639 times.
✓ Branch 2 taken 28548 times.
✓ Branch 3 taken 4752 times.
✓ Branch 4 taken 3180 times.
✓ Branch 5 taken 25368 times.
35939 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7470 {
7471 10571 v=1;
7472 10571 }
7473
7474 // Damaging boomerang sparkle?
7475
3/4
✓ Branch 0 taken 14718 times.
✓ Branch 1 taken 21221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14718 times.
35939 if(wpn3 && itemtype==itype_brang)
7476 {
7477 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7478 // whatever it just bounced off of if it's shielded from that direction.
7479
6/6
✓ Branch 0 taken 9664 times.
✓ Branch 1 taken 5054 times.
✓ Branch 2 taken 9297 times.
✓ Branch 3 taken 367 times.
✓ Branch 4 taken 4074 times.
✓ Branch 5 taken 5223 times.
14718 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7480 5223 direction=oppositeDir[direction];
7481 14718 }
7482
4/4
✓ Branch 0 taken 35321 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 14650 times.
✓ Branch 3 taken 20671 times.
35939 if(itemtype==itype_brang && get_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7483
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 35866 times.
35939 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7484
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 35866 times.
35939 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7485
5/10
✓ Branch 0 taken 35939 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35939 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35939 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 35939 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 35939 times.
✗ Branch 9 not taken.
35939 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7486 35939 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7487 35939 }
7488 267854 }
7489
7490 // For wPhantoms
7491 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7492 {
7493 if(frame%4) return;
7494
7495 int32_t arrow = -1;
7496
7497 for(int32_t i=0; i<Lwpns.Count(); i++)
7498 {
7499 weapon *w = (weapon*)Lwpns.spr(i);
7500
7501 if(w->id == wPhantom && w->type == type1)
7502 {
7503 arrow = i;
7504 break;
7505 }
7506 }
7507
7508 if(arrow==-1)
7509 {
7510 return;
7511 }
7512
7513 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7514 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7515 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7516 }
7517
7518 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7519 5152186 void HeroClass::PhantomsCleanup()
7520 {
7521
1/2
✓ Branch 0 taken 5152186 times.
✗ Branch 1 not taken.
5152186 if(Lwpns.idCount(wPhantom))
7522 {
7523 for(int32_t i=0; i<Lwpns.Count(); i++)
7524 {
7525 weapon *w = ((weapon *)Lwpns.spr(i));
7526 if ( w->id == wPhantom && !w->isScriptGenerated() )
7527 {
7528 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7529 {
7530 Lwpns.remove(w);
7531 }
7532 }
7533 }
7534 }
7535 5152186 }
7536
7537 //Waitframe handler for refilling operations
7538 4932 static void do_refill_waitframe()
7539 {
7540 4932 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,game->should_show_time(),sspUP);
7541
1/2
✓ Branch 0 taken 4932 times.
✗ Branch 1 not taken.
4932 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7542 {
7543 script_drawing_commands.Clear();
7544 if(DMaps[currdmap].passive_sub_script != 0)
7545 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7546 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
7547 {
7548 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
7549 passive_subscreen_waitdraw = false;
7550 }
7551 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
7552 }
7553 4932 advanceframe(true);
7554 4932 }
7555 //Special handler if it's a "fairy revive"
7556 static void do_death_refill_waitframe()
7557 {
7558 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7559 //This script should be able to draw a 'fairy saving the player' animation -Em
7560 do_refill_waitframe();
7561 }
7562
7563 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7564 {
7565 int32_t found_unowned = -1;
7566 for(int q = 0; q < MAXITEMS; ++q)
7567 {
7568 if(itemsbuf[q].family == itype_bottle && itemsbuf[q].misc1 == slot)
7569 {
7570 if(game->get_item(q))
7571 return q;
7572 if(unowned)
7573 found_unowned = q;
7574 }
7575 }
7576 return found_unowned;
7577 }
7578
7579 int32_t getPushDir(int32_t flag)
7580 {
7581 switch(flag)
7582 {
7583 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7584 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7585 case mfPUSHUINS:
7586 return up;
7587 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7588 return down;
7589 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7590 case mfPUSHLRINS: case mfPUSHLINS:
7591 return left;
7592 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7593 return right;
7594 }
7595 return -1;
7596 }
7597
7598 void post_item_collect();
7599
7600 // returns true when game over
7601 14922741 bool HeroClass::animate(int32_t)
7602 {
7603 14922741 int32_t lsave=0;
7604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14922741 times.
14922741 if(immortal > 0)
7605 --immortal;
7606 14922741 prompt_combo = 0;
7607
2/2
✓ Branch 0 taken 9770227 times.
✓ Branch 1 taken 5152514 times.
14922741 if (onpassivedmg)
7608 {
7609 9770227 onpassivedmg=false;
7610 9770227 }
7611
1/2
✓ Branch 0 taken 5152514 times.
✗ Branch 1 not taken.
5152514 else if (damageovertimeclk)
7612 {
7613 damageovertimeclk = 0;
7614 }
7615
7616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14922741 times.
14922741 if(cheats_execute_goto)
7617 {
7618 didpit=true;
7619 pitx=x;
7620 pity=y;
7621 dowarp(3,0);
7622 cheats_execute_goto=false;
7623 solid_update(false);
7624 return false;
7625 }
7626
7627
1/2
✓ Branch 0 taken 14922741 times.
✗ Branch 1 not taken.
14922741 if(cheats_execute_light)
7628 {
7629 naturaldark = !naturaldark;
7630 lighting(false, false, pal_litOVERRIDE);//Forcibly set permLit, overriding it's current setting
7631 cheats_execute_light = false;
7632 }
7633
7634
3/4
✓ Branch 0 taken 5152514 times.
✓ Branch 1 taken 9770227 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5152514 times.
14922741 if(action!=climbcovertop&&action!=climbcoverbottom)
7635 {
7636 5152514 climb_cover_x=-1000;
7637 5152514 climb_cover_y=-1000;
7638 5152514 }
7639
7640
1/2
✓ Branch 0 taken 14922741 times.
✗ Branch 1 not taken.
14922741 if(mirror_portal)
7641 {
7642 mirror_portal->animate(0);
7643 if(abs(x - mirror_portal->x) < 12
7644 && abs(y - mirror_portal->y) < 12)
7645 {
7646 if(can_mirror_portal)
7647 {
7648 //Store some values to restore if 'warp fails'
7649 int32_t tLastEntrance = lastentrance,
7650 tLastEntranceDMap = lastentrance_dmap,
7651 tContScr = game->get_continue_scrn(),
7652 tContDMap = game->get_continue_dmap();
7653 int32_t sourcescr = currscr, sourcedmap = currdmap;
7654 zfix tx = x, ty = y, tz = z;
7655 x = mirror_portal->x;
7656 y = mirror_portal->y;
7657
7658 int32_t weff = mirror_portal->weffect,
7659 wsfx = mirror_portal->wsfx;
7660
7661 FFCore.warp_player(wtIWARP, mirror_portal->destdmap, mirror_portal->destscr,
7662 -1, -1, weff, wsfx, 0, -1);
7663
7664 if(mirrorBonk()) //Invalid landing, warp back!
7665 {
7666 action = none; FFCore.setHeroAction(none);
7667 lastentrance = tLastEntrance;
7668 lastentrance_dmap = tLastEntranceDMap;
7669 game->set_continue_scrn(tContScr);
7670 game->set_continue_dmap(tContDMap);
7671 x = tx;
7672 y = ty;
7673 z = tz;
7674 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7675 wsfx, 0, -1);
7676 can_mirror_portal = false;
7677 }
7678 else game->clear_portal(); //Remove portal once used
7679 }
7680 }
7681 else can_mirror_portal = true;
7682 }
7683
7684
3/4
✓ Branch 0 taken 5149480 times.
✓ Branch 1 taken 9773261 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149480 times.
14922741 if(z<=8&&fakez<=8)
7685 {
7686
2/2
✓ Branch 0 taken 42395 times.
✓ Branch 1 taken 5107085 times.
5149480 if (get_bit(quest_rules, qr_GRASS_SENSITIVE))
7687 {
7688 42395 bool g1 = isGrassType(COMBOTYPE(x+4,y+15)), g2 = isGrassType(COMBOTYPE(x+11,y+15)), g3 = isGrassType(COMBOTYPE(x+4,y+9)), g4 = isGrassType(COMBOTYPE(x+11,y+9));
7689
2/2
✓ Branch 0 taken 41531 times.
✓ Branch 1 taken 864 times.
42395 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7690 {
7691
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g1 = g1 || isGrassType(COMBOTYPEL(1,x+4,y+15)) || isGrassType(COMBOTYPEL(2,x+4,y+15));
7692
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g2 = g2 || isGrassType(COMBOTYPEL(1,x+11,y+15)) || isGrassType(COMBOTYPEL(2,x+11,y+15));
7693
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g3 = g3 || isGrassType(COMBOTYPEL(1,x+4,y+9)) || isGrassType(COMBOTYPEL(2,x+4,y+9));
7694
2/4
✓ Branch 0 taken 864 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 864 times.
864 g4 = g4 || isGrassType(COMBOTYPEL(1,x+11,y+9)) || isGrassType(COMBOTYPEL(2,x+11,y+9));
7695 864 }
7696
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42395 if(g1 && g2 && g3 && g4)
7697 {
7698 if(decorations.idCount(dTALLGRASS)==0)
7699 {
7700 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7701 }
7702 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+12)].attribytes[3];
7703 if (action==walking)
7704 sfx_no_repeat(thesfx,pan((int32_t)x));
7705 }
7706 42395 }
7707 else
7708 {
7709 5107085 bool g1 = isGrassType(COMBOTYPE(x,y+15)), g2 = isGrassType(COMBOTYPE(x+15,y+15));
7710
2/2
✓ Branch 0 taken 24877 times.
✓ Branch 1 taken 5082208 times.
5107085 if(get_bit(quest_rules, qr_BUSHESONLAYERS1AND2))
7711 {
7712
2/4
✓ Branch 0 taken 24877 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24877 times.
24877 g1 = g1 || isGrassType(COMBOTYPEL(1,x,y+15)) || isGrassType(COMBOTYPEL(2,x,y+15));
7713
2/4
✓ Branch 0 taken 24877 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24877 times.
24877 g2 = g2 || isGrassType(COMBOTYPEL(1,x+15,y+15)) || isGrassType(COMBOTYPEL(2,x+15,y+15));
7714 24877 }
7715
4/4
✓ Branch 0 taken 41523 times.
✓ Branch 1 taken 5065562 times.
✓ Branch 2 taken 5567 times.
✓ Branch 3 taken 35956 times.
5107085 if(g1 && g2)
7716 {
7717
2/2
✓ Branch 0 taken 35437 times.
✓ Branch 1 taken 519 times.
35956 if(decorations.idCount(dTALLGRASS)==0)
7718 {
7719
3/6
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✗ Branch 5 not taken.
519 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0));
7720 519 }
7721 35956 int32_t thesfx = combobuf[MAPCOMBO(x+8,y+15)].attribytes[3];
7722
2/2
✓ Branch 0 taken 15245 times.
✓ Branch 1 taken 20711 times.
35956 if (action==walking )
7723 20711 sfx_no_repeat(thesfx,pan((int32_t)x));
7724 35956 }
7725 }
7726 5149480 }
7727
7728
2/2
✓ Branch 0 taken 10052712 times.
✓ Branch 1 taken 4870029 times.
14922741 if (get_bit(quest_rules, qr_SHALLOW_SENSITIVE))
7729 {
7730
19/26
✓ Branch 0 taken 279368 times.
✓ Branch 1 taken 9773344 times.
✓ Branch 2 taken 279368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 278089 times.
✓ Branch 5 taken 1279 times.
✓ Branch 6 taken 278089 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 277385 times.
✓ Branch 9 taken 704 times.
✓ Branch 10 taken 277385 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 277385 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 277385 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 277175 times.
✓ Branch 17 taken 210 times.
✓ Branch 18 taken 277175 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 277142 times.
✓ Branch 21 taken 33 times.
✓ Branch 22 taken 277082 times.
✓ Branch 23 taken 60 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 277082 times.
10052712 if (z == 0 && fakez == 0 && action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
7731 {
7732
2/2
✓ Branch 0 taken 253946 times.
✓ Branch 1 taken 23136 times.
301748 if (iswaterex(FFORCOMBO(x+11,y+15), currmap, currscr, -1, x+11,y+15, false, false, true, true)
7733
2/2
✓ Branch 0 taken 24666 times.
✓ Branch 1 taken 252416 times.
277082 && iswaterex(FFORCOMBO(x+4,y+15), currmap, currscr, -1, x+4,y+15, false, false, true, true)
7734
2/2
✓ Branch 0 taken 23788 times.
✓ Branch 1 taken 878 times.
24666 && iswaterex(FFORCOMBO(x+11,y+9), currmap, currscr, -1, x+11,y+9, false, false, true, true)
7735
2/2
✓ Branch 0 taken 23170 times.
✓ Branch 1 taken 618 times.
23788 && iswaterex(FFORCOMBO(x+4,y+9), currmap, currscr, -1, x+4,y+9, false, false, true, true))
7736 {
7737
2/2
✓ Branch 0 taken 22979 times.
✓ Branch 1 taken 157 times.
23136 if(decorations.idCount(dRIPPLES)==0)
7738 {
7739
3/6
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 157 times.
✗ Branch 5 not taken.
157 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7740 157 }
7741 23136 int32_t watercheck = iswaterex(FFORCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, false, false, true, true);
7742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23136 times.
23136 if (combobuf[watercheck].usrflags&cflag2)
7743 {
7744 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7745 {
7746 onpassivedmg = true;
7747 if (!damageovertimeclk)
7748 {
7749 int32_t curhp = game->get_life();
7750 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7751 else game->set_life(vbound(game->get_life()+combobuf[watercheck].attributes[1]/10000L, 0, game->get_maxlife()));
7752 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7753 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
7754 {
7755 hclk = 48;
7756 hitdir = -1;
7757 action = gothit; FFCore.setHeroAction(gothit);
7758 }
7759 }
7760 if (combobuf[watercheck].attribytes[1] > 0)
7761 {
7762 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7763 else --damageovertimeclk;
7764 }
7765 else damageovertimeclk = 0;
7766 }
7767 else damageovertimeclk = 0;
7768 }
7769 23136 else damageovertimeclk = 0;
7770 23136 int32_t thesfx = combobuf[watercheck].attribytes[0];
7771
3/4
✓ Branch 0 taken 22806 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 22806 times.
✗ Branch 3 not taken.
23136 if (combobuf[watercheck].type != cSHALLOWWATER || !get_bit(quest_rules, qr_OLD_SHALLOW_SFX))
7772 {
7773 330 thesfx = combobuf[watercheck].attribytes[5];
7774 330 }
7775
2/2
✓ Branch 0 taken 12794 times.
✓ Branch 1 taken 10342 times.
23136 if (action==walking)
7776 10342 sfx_no_repeat(thesfx,pan((int32_t)x));
7777 23136 }
7778 277082 }
7779 10052712 }
7780 else
7781 {
7782
7/8
✓ Branch 0 taken 4311 times.
✓ Branch 1 taken 4865718 times.
✓ Branch 2 taken 4156 times.
✓ Branch 3 taken 155 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4156 times.
✓ Branch 6 taken 4865873 times.
✓ Branch 7 taken 4156 times.
4870029 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0 && fakez==0)
7783 {
7784
2/2
✓ Branch 0 taken 4119 times.
✓ Branch 1 taken 37 times.
4156 if(decorations.idCount(dRIPPLES)==0)
7785 {
7786
3/6
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37 times.
✗ Branch 5 not taken.
37 decorations.add(new dRipples(x, y, dRIPPLES, 0));
7787 37 }
7788 4156 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
7789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4156 times.
4156 if (combobuf[watercheck].usrflags&cflag2)
7790 {
7791 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
7792 {
7793 onpassivedmg = true;
7794 if (!damageovertimeclk)
7795 {
7796 int32_t curhp = game->get_life();
7797 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
7798 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
7799 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
7800 }
7801 if (combobuf[watercheck].attribytes[1] > 0)
7802 {
7803 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
7804 else --damageovertimeclk;
7805 }
7806 else damageovertimeclk = 0;
7807 }
7808 else damageovertimeclk = 0;
7809 }
7810 4156 else damageovertimeclk = 0;
7811 4156 int32_t thesfx = combobuf[watercheck].attribytes[0];
7812
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 1180 times.
4156 if (action==walking )
7813 1180 sfx_no_repeat(thesfx,pan((int32_t)x));
7814 4156 }
7815 }
7816
7817
2/2
✓ Branch 0 taken 14922713 times.
✓ Branch 1 taken 28 times.
14922741 if(stomping)
7818 28 stomping = false;
7819
7820
2/2
✓ Branch 0 taken 14922527 times.
✓ Branch 1 taken 214 times.
14922741 if(getOnSideviewLadder())
7821 {
7822
4/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 214 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 214 times.
214 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
7823 {
7824 setOnSideviewLadder(false);
7825 }
7826
2/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 214 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
214 else if(CANFORCEFACEUP)
7827 {
7828 setDir(up);
7829 }
7830 214 }
7831
7832
6/8
✓ Branch 0 taken 5146833 times.
✓ Branch 1 taken 9775908 times.
✓ Branch 2 taken 5146129 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 5146129 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5146129 times.
14922741 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning)
7833 {
7834
2/2
✓ Branch 0 taken 4990856 times.
✓ Branch 1 taken 155273 times.
5146129 if(!get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
7835 {
7836 155273 checkchest(cCHEST);
7837 155273 checkchest(cLOCKEDCHEST);
7838 155273 checkchest(cBOSSCHEST);
7839 155273 }
7840
2/2
✓ Branch 0 taken 5120516 times.
✓ Branch 1 taken 25613 times.
5146129 if(!get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
7841 {
7842 25613 checkchest(cLOCKBLOCK);
7843 25613 checkchest(cBOSSLOCKBLOCK);
7844 25613 }
7845 5146129 }
7846 14922741 checksigns();
7847 14922741 checkgenpush();
7848
7849
4/4
✓ Branch 0 taken 4866296 times.
✓ Branch 1 taken 10056445 times.
✓ Branch 2 taken 2266 times.
✓ Branch 3 taken 4864030 times.
14922741 if(isStanding(true) && fall == 0)
7850 {
7851
1/2
✓ Branch 0 taken 4864030 times.
✗ Branch 1 not taken.
4864030 if(extra_jump_count > 0)
7852 extra_jump_count = 0;
7853 4864030 coyotetime = 0;
7854 4864030 }
7855
2/2
✓ Branch 0 taken 9772189 times.
✓ Branch 1 taken 286522 times.
10058711 else if(coyotetime < 65535)
7856 {
7857 286522 ++coyotetime;
7858 286522 }
7859
2/2
✓ Branch 0 taken 14912422 times.
✓ Branch 1 taken 10319 times.
14922741 if(can_use_item(itype_hoverboots,i_hoverboots))
7860 {
7861 10319 int32_t hoverid = current_item_id(itype_hoverboots);
7862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10319 times.
10319 if(!(itemsbuf[hoverid].flags & ITEM_FLAG1))
7863 {
7864
1/2
✓ Branch 0 taken 10319 times.
✗ Branch 1 not taken.
10319 if(hoverclk < 0) hoverclk = 0;
7865 10319 hoverflags &= ~HOV_OUT;
7866 10319 }
7867 10319 }
7868 14922741 bool platformfell2 = false;
7869 14922741 int32_t gravity3 = (zinit.gravity2/100);
7870 14922741 int32_t termv = (zinit.terminalv);
7871 14922741 int32_t rocs = getRocsPressed();
7872
2/2
✓ Branch 0 taken 14921674 times.
✓ Branch 1 taken 1067 times.
14922741 if (rocs != -1)
7873 {
7874 1067 itemdata const& itm = itemsbuf[rocs];
7875
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if (itm.flags & ITEM_FLAG2)
7876 {
7877 if ((!(itm.flags & ITEM_FLAG3) || fall < 0) &&
7878 (!(itm.flags & ITEM_FLAG4) || fall > 0)) gravity3 = itm.misc3;
7879 }
7880
1/2
✓ Branch 0 taken 1067 times.
✗ Branch 1 not taken.
1067 if (itm.flags & ITEM_FLAG5)
7881 {
7882 termv = itm.misc4;
7883 if (fall > termv) fall = termv;
7884 }
7885 1067 }
7886
2/2
✓ Branch 0 taken 257641 times.
✓ Branch 1 taken 14665100 times.
14922741 if(sideview_mode()) // Sideview gravity
7887 {
7888 //Handle falling through a platform
7889 257641 bool platformfell = false;
7890
4/4
✓ Branch 0 taken 130099 times.
✓ Branch 1 taken 127542 times.
✓ Branch 2 taken 130084 times.
✓ Branch 3 taken 15 times.
257641 if (on_sideview_solid_oldpos(x,y,old_x,old_y,true,3) && !on_sideview_solid_oldpos(x,y,old_x,old_y,false,3))
7891 {
7892
7/8
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 8 times.
15 if (!(!on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && Down())) platformfell = true;
7893 15 y+=1; //Fall down a pixel instantly, through the platform.
7894
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(fall < 0) fall = 0;
7895
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(jumping < 0) jumping = 0;
7896 15 platformfell2 = true;
7897 15 }
7898 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
7899
2/2
✓ Branch 0 taken 250696 times.
✓ Branch 1 taken 6945 times.
257641 if(!get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
7900 {
7901
14/22
✓ Branch 0 taken 6055 times.
✓ Branch 1 taken 890 times.
✓ Branch 2 taken 890 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 890 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 890 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 890 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 889 times.
✓ Branch 12 taken 889 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 889 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 889 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 889 times.
✓ Branch 20 taken 6944 times.
✓ Branch 21 taken 1 times.
7835 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,SWITCHBLOCK_STATE)
7902
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 889 times.
✓ Branch 2 taken 874 times.
✓ Branch 3 taken 15 times.
904 || ((y+(fall/100)<=0) &&
7903 // Extra checks if Smart Screen Scrolling is enabled
7904
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
7905 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up)))))))
7906 {
7907 1 fall = jumping = 0; // Bumped his head
7908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7909 y -= y.getInt()%8; //fix coords
7910 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
7911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
7912 {
7913 1 checkdamagecombos(x+4, x+12, y-1, y-1);
7914 1 }
7915 1 }
7916 6945 }
7917 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
7918
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 257641 times.
✓ Branch 2 taken 257641 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257641 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257641 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 257641 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 257641 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 214 times.
✓ Branch 13 taken 257427 times.
257641 if(!(toogam && Up()) && !drownclk && action!=rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall>0) && !getOnSideviewLadder())
7919 {
7920
1/2
✓ Branch 0 taken 257427 times.
✗ Branch 1 not taken.
257427 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
7921 //zprint2("ydif is: %d\n", ydiff);
7922 //zprint2("ydif is: %d\n", (int32_t)fall);
7923 257427 falling_oldy = y; // Stomp Boots-related variable
7924
5/8
✓ Branch 0 taken 48138 times.
✓ Branch 1 taken 209289 times.
✓ Branch 2 taken 48138 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48138 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257427 times.
✗ Branch 7 not taken.
257427 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (((y.getInt()+ydiff+15)&0xF0)!=((y.getInt()+15)&0xF0)) && !platform_fallthrough())
7925 {
7926 ydiff -= (y.getInt()+ydiff)%16;
7927 }
7928
4/4
✓ Branch 0 taken 68431 times.
✓ Branch 1 taken 188996 times.
✓ Branch 2 taken 66794 times.
✓ Branch 3 taken 1637 times.
257427 if(ydiff && !get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
7929 {
7930
2/2
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 764 times.
1637 if(ydiff > 0)
7931 {
7932
2/2
✓ Branch 0 taken 831 times.
✓ Branch 1 taken 1607 times.
2438 for(auto q = 0; q < ydiff; ++q)
7933 {
7934
2/2
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 42 times.
1607 if(on_sideview_solid_oldpos(x,y+q,old_x,old_y))
7935 {
7936 42 ydiff = q;
7937 42 break;
7938 }
7939 1565 }
7940 873 }
7941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 764 times.
764 else if(ydiff < 0)
7942 {
7943
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 1492 times.
2256 for(auto q = 0; q > ydiff; --q)
7944 {
7945
1/2
✓ Branch 0 taken 1492 times.
✗ Branch 1 not taken.
2984 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
7946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1492 times.
1492 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
7947 {
7948 ydiff = q;
7949 break;
7950 }
7951 1492 }
7952 764 }
7953 1637 }
7954 257427 y+=ydiff;
7955 257427 hs_starty+=ydiff;
7956
7957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 257427 times.
257427 for(int32_t j=0; j<chainlinks.Count(); j++)
7958 {
7959 chainlinks.spr(j)->y+=ydiff;
7960 }
7961
7962
1/2
✓ Branch 0 taken 257427 times.
✗ Branch 1 not taken.
257427 if(Lwpns.idFirst(wHookshot)>-1)
7963 {
7964 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
7965 }
7966
7967
1/2
✓ Branch 0 taken 257427 times.
✗ Branch 1 not taken.
257427 if(Lwpns.idFirst(wHSHandle)>-1)
7968 {
7969 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
7970 }
7971 257427 }
7972
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
214 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
7973 {
7974 fall = hoverclk = jumping = 0;
7975 inair = false;
7976 hoverflags = 0;
7977 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
7978 {
7979 WalkflagInfo info;
7980 if (game->get_watergrav()<0)
7981 {
7982 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
7983 execute(info);
7984 }
7985 else
7986 {
7987 info = walkflag(x,y+15+2,2,down);
7988 execute(info);
7989 }
7990 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)-2), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false))) y+=(game->get_watergrav()/10000.0);
7991 }
7992 }
7993 // Stop hovering/falling if you land on something.
7994 257641 bool needFall = false;
7995
7/8
✓ Branch 0 taken 127050 times.
✓ Branch 1 taken 130591 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 257641 times.
✓ Branch 4 taken 130805 times.
✓ Branch 5 taken 126836 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 130792 times.
257641 if((on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
7996 {
7997 130792 stop_item_sfx(itype_hoverboots);
7998
1/2
✓ Branch 0 taken 124016 times.
✗ Branch 1 not taken.
254808 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE)
7999
2/2
✓ Branch 0 taken 126660 times.
✓ Branch 1 taken 4132 times.
130792 && !getOnSideviewLadder()
8000
3/4
✓ Branch 0 taken 126660 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124016 times.
✓ Branch 3 taken 2644 times.
126660 && (fall > 0 || get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON)))
8001 126660 y-=(int32_t)y%8; //fix position
8002 130792 fall = hoverclk = jumping = 0;
8003 130792 inair = false;
8004 130792 hoverflags = 0;
8005
8006
4/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 130784 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
130792 if(y>=160 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) // Landed on the bottommost screen.
8007 8 y = 160;
8008 130792 }
8009 // Stop hovering if you press down.
8010
3/6
✓ Branch 0 taken 126849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 126849 times.
✗ Branch 5 not taken.
126849 else if((hoverclk>0 || ladderx || laddery) && DrunkDown())
8011 {
8012 stop_item_sfx(itype_hoverboots);
8013 hoverclk = -hoverclk;
8014 reset_ladder();
8015 fall = gravity3;
8016 inair = false;
8017 }
8018
10/12
✓ Branch 0 taken 126849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3583 times.
✓ Branch 3 taken 123266 times.
✓ Branch 4 taken 1832 times.
✓ Branch 5 taken 1751 times.
✓ Branch 6 taken 1824 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1824 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 281 times.
✓ Branch 11 taken 1543 times.
126849 else if (hoverclk < 1 && !inair && fall == 0 && !platformfell && !IsSideSwim() && justmoved <= 0)
8019 {
8020 1543 zfix my = y + 4;
8021 1543 needFall = true;
8022
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 3103 times.
3751 for (zfix ty = y+1; ty < my; ++ty)
8023 {
8024 //if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 1)) break;
8025
2/2
✓ Branch 0 taken 2208 times.
✓ Branch 1 taken 895 times.
3103 if (on_sideview_solid_oldpos(x, ty,old_x,old_y, false, 0))
8026 {
8027 895 y = ty;
8028
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 746 times.
895 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
8029 {
8030
2/2
✓ Branch 0 taken 737 times.
✓ Branch 1 taken 9 times.
746 if(!slopeid)
8031 9 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
8032 746 onplatid = 5;
8033 746 }
8034 895 needFall = false;
8035 895 break;
8036 }
8037 2208 }
8038 1543 }
8039 125306 else needFall = true;
8040 // Continue falling.
8041
8042
4/4
✓ Branch 0 taken 250266 times.
✓ Branch 1 taken 7375 times.
✓ Branch 2 taken 131687 times.
✓ Branch 3 taken 118579 times.
257641 if(fall <= termv && needFall)
8043 {
8044 118579 inair = true;
8045
3/4
✓ Branch 0 taken 47130 times.
✓ Branch 1 taken 71449 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 47130 times.
118579 if(fall != 0 || hoverclk>0)
8046 71449 jumping++;
8047
8048 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8049
2/2
✓ Branch 0 taken 116656 times.
✓ Branch 1 taken 1923 times.
118579 if(get_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON))
8050 {
8051
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 116656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116656 times.
✓ Branch 4 taken 116065 times.
✓ Branch 5 taken 591 times.
233312 if((_walkflag(x+4,y-(bigHitbox?9:1),0,SWITCHBLOCK_STATE)
8052
4/4
✓ Branch 0 taken 111190 times.
✓ Branch 1 taken 5466 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 110284 times.
116656 || (y<=(bigHitbox?9:1) &&
8053 // Extra checks if Smart Screen Scrolling is enabled
8054
2/6
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 906 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
906 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8055 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8056
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
5466 && fall < 0)
8057 {
8058 591 fall = jumping = 0; // Bumped his head
8059
8060 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8061
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 110 times.
591 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8062 {
8063 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8064 110 }
8065 591 }
8066 116656 }
8067 else
8068 {
8069
8/16
✗ Branch 0 not taken.
✓ Branch 1 taken 1923 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1923 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1923 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1923 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1923 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1923 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1923 times.
✓ Branch 14 taken 1923 times.
✗ Branch 15 not taken.
3846 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,SWITCHBLOCK_STATE)
8070
3/4
✓ Branch 0 taken 1923 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 1904 times.
1923 || ((y<=0) &&
8071 // Extra checks if Smart Screen Scrolling is enabled
8072
2/6
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19 (nextcombo_wf(up) || ((get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE)) &&
8073 !(tmpscr->flags2&wfUP)) && (nextcombo_solid(up))))))
8074 && fall < 0)
8075 {
8076 fall = jumping = 0; // Bumped his head
8077 y -= y.getInt()%8; //fix coords
8078 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8079 if ( !get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8080 {
8081 checkdamagecombos(x+4, x+12, y-1, y-1);
8082 }
8083 }
8084 }
8085
8086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118579 times.
118579 if(hoverclk > 0)
8087 {
8088 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8089 {
8090 --hoverclk;
8091 }
8092
8093 if(!hoverclk && !ladderx && !laddery)
8094 {
8095 fall += gravity3;
8096 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8097 }
8098 }
8099
5/12
✓ Branch 0 taken 85854 times.
✓ Branch 1 taken 32725 times.
✓ Branch 2 taken 47827 times.
✓ Branch 3 taken 38027 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47827 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
118579 else if(fall+gravity3 > 0 && fall<=0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
8100 {
8101 int32_t itemid = current_item_id(itype_hoverboots);
8102 if(hoverclk < 0)
8103 hoverclk = -hoverclk;
8104 else
8105 {
8106 fall = jumping = 0;
8107 if(itemsbuf[itemid].misc1)
8108 hoverclk = itemsbuf[itemid].misc1;
8109 else
8110 {
8111 hoverclk = 1;
8112 hoverflags |= HOV_INF;
8113 }
8114
8115
8116 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
8117 }
8118 if(itemsbuf[itemid].wpn)
8119 decorations.add(new dHover(x, y, dHOVER, 0));
8120 }
8121
4/8
✓ Branch 0 taken 118579 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118579 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 118579 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 118579 times.
118579 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8122 {
8123 118579 fall += gravity3;
8124
8125 118579 }
8126 118579 }
8127 257641 }
8128 else // Topdown gravity
8129 {
8130
4/4
✓ Branch 0 taken 9770228 times.
✓ Branch 1 taken 4894872 times.
✓ Branch 2 taken 4894024 times.
✓ Branch 3 taken 848 times.
14665100 if (!(moveflags & FLAG_NO_FAKE_Z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8131
4/4
✓ Branch 0 taken 9770228 times.
✓ Branch 1 taken 4894872 times.
✓ Branch 2 taken 4894024 times.
✓ Branch 3 taken 848 times.
14665100 if (!(moveflags & FLAG_NO_REAL_Z)) z-=fall/(spins && fall>0 ? 200:100);
8132
4/4
✓ Branch 0 taken 4891604 times.
✓ Branch 1 taken 9773496 times.
✓ Branch 2 taken 9776764 times.
✓ Branch 3 taken 14668368 times.
14665100 if(z>0||fakez>0)
8133 {
8134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19550260 switch(action)
8135 {
8136 case swimming:
8137 {
8138 diveclk=0;
8139 action=walking; FFCore.setHeroAction(walking);
8140
8141 break;
8142 }
8143 case waterhold1:
8144 {
8145 action=landhold1; FFCore.setHeroAction(landhold1);
8146 break;
8147 }
8148
8149 case waterhold2:
8150 {
8151 action=landhold2; FFCore.setHeroAction(landhold2);
8152 break;
8153 }
8154
8155 default:
8156 3268 break;
8157 }
8158 3268 }
8159
8160
2/2
✓ Branch 0 taken 7331 times.
✓ Branch 1 taken 14671636 times.
14678967 for(int32_t j=0; j<chainlinks.Count(); j++)
8161 {
8162 7331 chainlinks.spr(j)->z=z;
8163 7331 chainlinks.spr(j)->fakez=fakez;
8164 7331 }
8165
8166
2/2
✓ Branch 0 taken 14669831 times.
✓ Branch 1 taken 1805 times.
14671636 if(Lwpns.idFirst(wHookshot)>-1)
8167 {
8168 1805 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8169 1805 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8170 1805 }
8171
8172
2/2
✓ Branch 0 taken 14669756 times.
✓ Branch 1 taken 1880 times.
14671636 if(Lwpns.idFirst(wHSHandle)>-1)
8173 {
8174 1880 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8175 1880 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8176 1880 }
8177
8178
3/4
✓ Branch 0 taken 4891604 times.
✓ Branch 1 taken 9780032 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4891604 times.
14671636 if(z<=0&&!(moveflags & FLAG_NO_REAL_Z))
8179 {
8180
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4891604 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4891604 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8181 {
8182
2/2
✓ Branch 0 taken 4891576 times.
✓ Branch 1 taken 28 times.
4891604 if(fall > 0)
8183 {
8184
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✓ Branch 7 taken 6 times.
28 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8185 6 sfx(WAV_ZN1SPLASH,x.getInt());
8186
8187 28 stomping = true;
8188 28 }
8189 4891604 }
8190 4891604 z = fall = 0;
8191
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4891604 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4891604 if (fakez <= 0 || (moveflags & FLAG_NO_FAKE_Z))
8192 {
8193 4891604 jumping = 0;
8194
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 4891350 times.
4891604 if(check_pitslide(true) == -1)
8195 {
8196 4891350 hoverclk = 0;
8197 4891350 hoverflags = 0;
8198 4891350 }
8199
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
254 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8200 {
8201
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8202 {
8203 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8204 }
8205 17 }
8206 4891604 }
8207 4891604 }
8208
3/4
✓ Branch 0 taken 4894872 times.
✓ Branch 1 taken 9776764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4894872 times.
14671636 if(fakez<=0&&!(moveflags & FLAG_NO_FAKE_Z))
8209 {
8210
3/4
✓ Branch 0 taken 3268 times.
✓ Branch 1 taken 4891604 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3268 times.
4894872 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8211 {
8212
1/2
✓ Branch 0 taken 4891604 times.
✗ Branch 1 not taken.
4891604 if(fakefall > 0)
8213 {
8214 if((iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER)
8215 sfx(WAV_ZN1SPLASH,x.getInt());
8216
8217 stomping = true;
8218 }
8219 4891604 }
8220 4894872 fakez = fakefall = 0;
8221
3/4
✓ Branch 0 taken 3268 times.
✓ Branch 1 taken 4891604 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3268 times.
4894872 if (z <= 0 || (moveflags & FLAG_NO_REAL_Z))
8222 {
8223 4891604 jumping = 0;
8224
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 4891350 times.
4891604 if(check_pitslide(true) == -1)
8225 {
8226 4891350 hoverclk = 0;
8227 4891350 hoverflags = 0;
8228 4891350 }
8229
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 237 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
254 else if(hoverclk > 0 && !(hoverflags&HOV_INF))
8230 {
8231
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!--hoverclk)
8232 {
8233 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8234 }
8235 17 }
8236 4891604 }
8237 4894872 }
8238
8/10
✓ Branch 0 taken 4894849 times.
✓ Branch 1 taken 9776787 times.
✓ Branch 2 taken 4894849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4888382 times.
✓ Branch 5 taken 6467 times.
✓ Branch 6 taken 4891627 times.
✓ Branch 7 taken 4891627 times.
✓ Branch 8 taken 4891627 times.
✗ Branch 9 not taken.
14671636 if(fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z>0 || fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)
8239 {
8240
4/6
✓ Branch 0 taken 2715 times.
✓ Branch 1 taken 530 times.
✓ Branch 2 taken 2715 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2715 times.
9780009 if(fall != 0 || fakefall != 0 || hoverclk>0)
8241 530 jumping++;
8242
8243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3245 times.
3245 if(hoverclk > 0)
8244 {
8245 if(hoverclk > 0 && !(hoverflags&HOV_INF))
8246 {
8247 --hoverclk;
8248 }
8249
8250 if(!hoverclk)
8251 {
8252 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8253 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8254 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
8255 }
8256 }
8257
9/16
✓ Branch 0 taken 3057 times.
✓ Branch 1 taken 188 times.
✓ Branch 2 taken 2725 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 2725 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 520 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 520 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 520 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3245 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
3245 else if(((fall+(int32_t)(zinit.gravity2 / 100) > 0 && fall<=0 && !(moveflags & FLAG_NO_REAL_Z) && z > 0) || (fakefall+gravity3 > 0 && fakefall<=0 && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0)) && can_use_item(itype_hoverboots,i_hoverboots) && !(hoverflags & HOV_OUT))
8258 {
8259 if(hoverclk < 0)
8260 hoverclk = -hoverclk;
8261 else
8262 {
8263 fall = 0;
8264 fakefall = 0;
8265 int32_t itemid = current_item_id(itype_hoverboots);
8266 if(itemsbuf[itemid].misc1)
8267 hoverclk = itemsbuf[itemid].misc1;
8268 else
8269 {
8270 hoverclk = 1;
8271 hoverflags |= HOV_INF;
8272 }
8273 sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(x.getInt()));
8274 }
8275 decorations.add(new dHover(x, y, dHOVER, 0));
8276 }
8277 else
8278 {
8279
3/6
✓ Branch 0 taken 3245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3245 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3245 times.
3245 if (fall <= termv && !(moveflags & FLAG_NO_REAL_Z) && z > 0) fall += gravity3;
8280
3/6
✓ Branch 0 taken 3245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3245 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3245 times.
✗ Branch 5 not taken.
3245 if (fakefall <= termv && !(moveflags & FLAG_NO_FAKE_Z) && fakez > 0) fakefall += gravity3;
8281 }
8282 3245 }
8283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4894872 times.
4894872 if (fakez<0) fakez = 0;
8284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4894872 times.
4894872 if (z<0) z = 0;
8285 }
8286
8287
1/2
✓ Branch 0 taken 5152513 times.
✗ Branch 1 not taken.
5152513 if(drunkclk)
8288 {
8289 --drunkclk;
8290 }
8291
8292
1/2
✓ Branch 0 taken 5152513 times.
✗ Branch 1 not taken.
5152513 if(lstunclock > 0)
8293 {
8294 // also cancel Hero's attack
8295 attackclk = 0;
8296
8297 if( FFCore.getHeroAction() != stunned )
8298 {
8299 tempaction=action; //update so future checks won't do this
8300 //action=freeze; //setting this makes the player invincible while stunned -V
8301 FFCore.setHeroAction(stunned);
8302 }
8303 --lstunclock;
8304 }
8305 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8306 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8307
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5152513 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5152513 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8308 {
8309 action=tempaction; FFCore.setHeroAction(tempaction);
8310 //zprint("Unfreezing hero to action: %d\n", (int32_t)tempaction);
8311 //action=none; FFCore.setHeroAction(none);
8312 }
8313
8314
1/2
✓ Branch 0 taken 5152513 times.
✗ Branch 1 not taken.
5152513 if( lbunnyclock > 0 )
8315 {
8316 --lbunnyclock;
8317 }
8318
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 5150588 times.
5152513 if(DMaps[currdmap].flags&dmfBUNNYIFNOPEARL)
8319 {
8320 1925 int32_t itemid = current_item_id(itype_pearl);
8321
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 1802 times.
1925 if(itemid > -1)
8322 {
8323
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 1 times.
123 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8324 1 lbunnyclock = 0;
8325 123 }
8326
2/2
✓ Branch 0 taken 1801 times.
✓ Branch 1 taken 1 times.
1802 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8327 {
8328 1 lbunnyclock = -1;
8329 1 }
8330 1925 }
8331
1/2
✓ Branch 0 taken 5150588 times.
✗ Branch 1 not taken.
5150588 else if(lbunnyclock == -1) //dmap-caused bunny effect
8332 {
8333 lbunnyclock = 0;
8334 }
8335
8336
12/16
✓ Branch 0 taken 5146103 times.
✓ Branch 1 taken 6410 times.
✓ Branch 2 taken 4487627 times.
✓ Branch 3 taken 658476 times.
✓ Branch 4 taken 4487627 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1206 times.
✓ Branch 7 taken 4486421 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1206 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 4485818 times.
✓ Branch 13 taken 1809 times.
✓ Branch 14 taken 37471 times.
✓ Branch 15 taken 4447753 times.
5152513 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && (fall==0 || fakefall==0 || z>0 || fakez>0) && charging==0 && spins<=5
8337
2/2
✓ Branch 0 taken 4485224 times.
✓ Branch 1 taken 594 times.
4485818 && action != gothit)
8338 {
8339
2/3
✓ Branch 0 taken 1971613 times.
✓ Branch 1 taken 2476140 times.
✗ Branch 2 not taken.
4447753 switch(dir)
8340 {
8341 case up:
8342 case down:
8343 1971613 x=(x.getInt()+4)&0xFFF8;
8344 1971613 break;
8345
8346 case left:
8347 case right:
8348 2476140 y=(y.getInt()+4)&0xFFF8;
8349 2476140 break;
8350 }
8351 4447753 }
8352
8353
4/4
✓ Branch 0 taken 92913 times.
✓ Branch 1 taken 5059600 times.
✓ Branch 2 taken 56861 times.
✓ Branch 3 taken 36052 times.
5152513 if((watch==true) && clockclk)
8354 {
8355 36052 --clockclk;
8356
8357
2/2
✓ Branch 0 taken 35953 times.
✓ Branch 1 taken 99 times.
36052 if(!clockclk)
8358 {
8359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(cheat_superman==false)
8360 {
8361 99 setClock(false);
8362 99 }
8363
8364 99 watch=false;
8365
8366
2/2
✓ Branch 0 taken 50688 times.
✓ Branch 1 taken 99 times.
50787 for(int32_t i=0; i<eMAXGUYS; i++)
8367 {
8368
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 50688 times.
50694 for(int32_t zoras=0; zoras<clock_zoras[i]; zoras++)
8369 {
8370 6 addenemy(0,0,i,0);
8371 6 }
8372 50688 }
8373 99 }
8374 36052 }
8375
8376
3/4
✓ Branch 0 taken 5150633 times.
✓ Branch 1 taken 1880 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5150633 times.
5152513 if(hookshot_frozen || switch_hooked)
8377 {
8378
3/4
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 1805 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
1880 if(hookshot_used || switch_hooked)
8379 {
8380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1805 times.
1805 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8381 1805 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8382
8383
3/4
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 511 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1294 times.
1805 if(pull_hero || switch_hooked)
8384 {
8385
3/4
✓ Branch 0 taken 451 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 451 times.
511 if(hs_switcher || switch_hooked)
8386 {
8387 60 hs_fix = false;
8388
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(switchhookclk)
8389 {
8390 60 --switchhookclk;
8391
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 59 times.
60 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8392 {
8393
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8394 reset_hookshot();
8395 else
8396 {
8397 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8398 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8399
8400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1) //Switching combos
8401 {
8402 uint16_t targpos = hooked_combopos, plpos = COMBOPOS(x+8,y+8);
8403 if(targpos < 176 && plpos < 176 && hooked_layerbits)
8404 {
8405 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8406 for(int q = max_layer; q > -1; --q)
8407 {
8408 if(!(hooked_layerbits & (1<<q)))
8409 continue; //non-switching layer
8410 mapscr* scr = FFCore.tempScreens[q];
8411 newcombo const& cmb = combobuf[scr->data[targpos]];
8412 int32_t srcfl = scr->sflag[targpos];
8413 newcombo const& comb2 = combobuf[scr->data[plpos]];
8414 int32_t c = scr->data[plpos], cs = scr->cset[plpos], fl = scr->sflag[plpos];
8415 //{Check push status
8416 bool isFakePush = false;
8417 if(cmb.type == cSWITCHHOOK)
8418 {
8419 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8420 isFakePush = true;
8421 }
8422 bool isPush = isFakePush;
8423 if(!isPush) switch(srcfl)
8424 {
8425 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8426 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8427 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8428 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8429 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8430 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8431 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8432 isPush = true;
8433 }
8434 if(!isPush) switch(cmb.flag)
8435 {
8436 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8437 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8438 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8439 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8440 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8441 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8442 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8443 isPush = true;
8444 }
8445 if(srcfl==mfPUSHED) isPush = false;
8446 //}
8447 if(cmb.type == cSWITCHHOOK) //custom flags and such
8448 {
8449 if(cmb.usrflags&cflag3) //Breaks on swap
8450 {
8451 int32_t it = -1;
8452 int32_t thedropset = -1;
8453 if(cmb.usrflags&cflag4) //drop item
8454 {
8455 if(cmb.usrflags&cflag5)
8456 it = cmb.attribytes[2];
8457 else
8458 {
8459 it = select_dropitem(cmb.attribytes[2]);
8460 thedropset = cmb.attribytes[2];
8461 }
8462 }
8463
8464 breakable* br = new breakable(x, y, zfix(0),
8465 cmb, scr->cset[targpos], it, thedropset, cmb.attribytes[2],
8466 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8467 br->switch_hooked = true;
8468 decorations.add(br);
8469 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8470 hooked_undercombos[q] = -1;
8471
8472 if(cmb.usrflags&cflag6)
8473 {
8474 scr->data[targpos]++;
8475 }
8476 else
8477 {
8478 scr->data[targpos] = scr->undercombo;
8479 scr->cset[targpos] = scr->undercset;
8480 if(cmb.usrflags&cflag2)
8481 scr->sflag[targpos] = 0;
8482 }
8483 }
8484 else if(isPush)
8485 {
8486 //Simulate a block clicking into place
8487 movingblock mtemp;
8488 mtemp.clear();
8489 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8490 mtemp.dir = getPushDir(scr->sflag[targpos]);
8491 if(mtemp.dir < 0)
8492 mtemp.dir = getPushDir(cmb.flag);
8493 mtemp.clk = 1;
8494 if(isFakePush)
8495 mtemp.force_many = true;
8496 mtemp.animate(0);
8497 if((mtemp.bhole || mtemp.trigger)
8498 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
8499 || comb2.flag == mfBLOCKTRIGGER
8500 || comb2.flag == mfBLOCKHOLE))
8501 {
8502 scr->data[targpos] = scr->undercombo;
8503 scr->cset[targpos] = scr->undercset;
8504 scr->sflag[targpos] = 0;
8505 }
8506 else
8507 {
8508 scr->data[targpos] = c;
8509 scr->cset[targpos] = cs;
8510 if(cmb.usrflags&cflag2)
8511 scr->sflag[targpos] = fl;
8512 else
8513 scr->sflag[targpos] = 0;
8514 }
8515 }
8516 else
8517 {
8518 scr->data[plpos] = scr->data[targpos];
8519 scr->cset[plpos] = scr->cset[targpos];
8520 if(cmb.usrflags&cflag2)
8521 scr->sflag[plpos] = scr->sflag[targpos];
8522 scr->data[targpos] = c;
8523 scr->cset[targpos] = cs;
8524 if(cmb.usrflags&cflag2)
8525 scr->sflag[targpos] = fl;
8526 }
8527 }
8528 else if(isCuttableType(cmb.type)) //Break and drop effects
8529 {
8530 int32_t breakcs = scr->cset[targpos];
8531 if(isCuttableNextType(cmb.type)) //next instead of undercmb
8532 {
8533 scr->data[targpos]++;
8534 }
8535 else
8536 {
8537 scr->data[targpos] = scr->undercombo;
8538 scr->cset[targpos] = scr->undercset;
8539 scr->sflag[targpos] = 0;
8540 }
8541
8542 int32_t it = -1;
8543 int32_t thedropset = -1;
8544 if(isCuttableItemType(cmb.type)) //Drop an item
8545 {
8546 if ( (cmb.usrflags&cflag2) )
8547 {
8548 if(cmb.usrflags&cflag11)
8549 it = cmb.attribytes[1];
8550 else
8551 {
8552 it = select_dropitem(cmb.attribytes[1]);
8553 thedropset = cmb.attribytes[1];
8554 }
8555 }
8556 else
8557 {
8558 it = select_dropitem(12);
8559 thedropset = 12;
8560 }
8561 }
8562
8563 byte breaksfx = 0;
8564 if(get_bit(quest_rules,qr_MORESOUNDS)) //SFX
8565 {
8566 if (cmb.usrflags&cflag3)
8567 {
8568 breaksfx = cmb.attribytes[2];
8569 }
8570 else if(isBushType(cmb.type)
8571 || isFlowersType(cmb.type)
8572 || isGrassType(cmb.type))
8573 {
8574 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
8575 }
8576 }
8577
8578 //Clipping sprite
8579 int16_t decotype = (cmb.usrflags & cflag1) ?
8580 ((cmb.usrflags & cflag10)
8581 ? (cmb.attribytes[0])
8582 : (-1))
8583 : (0);
8584 if(decotype > 3) decotype = 0;
8585 if(!decotype)
8586 decotype = (isBushType(cmb.type) ? 1
8587 : (isFlowersType(cmb.type) ? 2
8588 : (isGrassType(cmb.type) ? 3
8589 : ((cmb.usrflags & cflag1) ? -1
8590 : -2))));
8591
8592 breakable* br = new breakable(x, y, zfix(0),
8593 cmb, breakcs, it, thedropset, breaksfx,
8594 decotype, cmb.attribytes[0], switchhookclk);
8595 br->switch_hooked = true;
8596 decorations.add(br);
8597 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8598 hooked_undercombos[q] = -1;
8599 }
8600 else //Unknown type, just swap combos.
8601 {
8602 if(isPush)
8603 {
8604 //Simulate a block clicking into place
8605 movingblock mtemp;
8606 mtemp.clear();
8607 mtemp.set(COMBOX(plpos),COMBOY(plpos),scr->data[targpos],scr->cset[targpos],q,scr->sflag[targpos]);
8608 mtemp.dir = getPushDir(scr->sflag[targpos]);
8609 if(mtemp.dir < 0)
8610 mtemp.dir = getPushDir(cmb.flag);
8611 mtemp.clk = 1;
8612 mtemp.animate(0);
8613 if(mtemp.bhole || mtemp.trigger)
8614 {
8615 scr->data[targpos] = scr->undercombo;
8616 scr->cset[targpos] = scr->undercset;
8617 scr->sflag[targpos] = 0;
8618 }
8619 else
8620 {
8621 scr->data[targpos] = c;
8622 scr->cset[targpos] = cs;
8623 scr->sflag[targpos] = 0;
8624 }
8625 }
8626 else
8627 {
8628 scr->data[plpos] = scr->data[targpos];
8629 scr->cset[plpos] = scr->cset[targpos];
8630 scr->data[targpos] = c;
8631 scr->cset[targpos] = cs;
8632 }
8633 }
8634 }
8635 if(switchhook_cost_item > -1)
8636 paymagiccost(switchhook_cost_item);
8637 zfix tx = x, ty = y;
8638 //Position the player at the combo
8639 x = COMBOX(targpos);
8640 y = COMBOY(targpos);
8641 dir = oppositeDir[dir];
8642 if(w && hw)
8643 {
8644 //Calculate chain shift
8645 zfix dx = (x-tx);
8646 zfix dy = (y-ty);
8647 if(w->dir < 4)
8648 {
8649 if(w->dir & 2)
8650 dx = 0;
8651 else dy = 0;
8652 }
8653 //Position the hook head at the handle
8654 w->x = hw->x + dx;
8655 w->y = hw->y + dy;
8656 w->dir = oppositeDir[w->dir];
8657 w->doAutoRotate(true);
8658 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8659 w->flip ^= hflip;
8660 //Position the handle appropriately
8661 hw->x = x-(hw->x-tx);
8662 hw->y = y-(hw->y-ty);
8663 hw->dir = oppositeDir[hw->dir];
8664 hw->doAutoRotate(true);
8665 hw->flip ^= hflip;
8666 //Move chains
8667 for(int32_t j=0; j<chainlinks.Count(); j++)
8668 {
8669 chainlinks.spr(j)->x += dx;
8670 chainlinks.spr(j)->y += dy;
8671 }
8672 }
8673 hooked_combopos = plpos; //flip positions
8674 }
8675 else reset_hookshot();
8676 }
8677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object) //Switching an object
8678 {
8679
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(switchhook_cost_item > -1)
8680 paymagiccost(switchhook_cost_item);
8681 1 zfix tx = x, ty = y;
8682 //Position the player at the object
8683 1 x = switching_object->x;
8684 1 y = switching_object->y;
8685 1 dir = oppositeDir[dir];
8686 //Position the object at the player
8687 1 switching_object->x = tx;
8688 1 switching_object->y = ty;
8689
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
8690 switching_object->dir = oppositeDir[switching_object->dir];
8691 1 solid_update(false);
8692 1 switching_object->solid_update(false);
8693
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(item* it = dynamic_cast<item*>(switching_object))
8694 {
8695 if(itemsbuf[it->id].family == itype_fairy && itemsbuf[it->id].misc3)
8696 {
8697 movefairynew2(it->x, it->y, *it);
8698 }
8699 }
8700
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(w && hw) //!TODO No fucking clue if diagonals work
8701 {
8702 //Calculate chain shift
8703 1 zfix dx = (x-tx);
8704 1 zfix dy = (y-ty);
8705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w->dir < 4)
8706 {
8707
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->dir & 2)
8708 1 dx = 0;
8709 else dy = 0;
8710 1 }
8711 //Position the hook head at the handle
8712 1 w->x = hw->x + dx;
8713 1 w->y = hw->y + dy;
8714 1 w->dir = oppositeDir[w->dir];
8715 1 w->doAutoRotate(true);
8716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
8717 1 w->flip ^= hflip;
8718 1 w->solid_update(false);
8719 //Position the handle appropriately
8720 1 hw->x = x-(hw->x-tx);
8721 1 hw->y = y-(hw->y-ty);
8722 1 hw->dir = oppositeDir[hw->dir];
8723 1 hw->doAutoRotate(true);
8724 1 hw->flip ^= hflip;
8725 1 hw->solid_update(false);
8726 //Move chains
8727
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
8728 {
8729 5 chainlinks.spr(j)->x += dx;
8730 5 chainlinks.spr(j)->y += dy;
8731 5 }
8732 1 }
8733 1 }
8734 }
8735 1 }
8736
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 1 times.
59 else if(!switchhookclk)
8737 {
8738 1 reset_hookshot();
8739 1 }
8740 60 }
8741 else reset_hookshot();
8742 60 }
8743 else
8744 {
8745 sprite *t;
8746 int32_t i;
8747
8748
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 467 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 451 times.
467 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
8749 {
8750 /* do nothing */
8751 16 }
8752
8753 451 t = Lwpns.spr(i);
8754
8755
2/2
✓ Branch 0 taken 918 times.
✓ Branch 1 taken 451 times.
1369 for(i=0; i<Lwpns.Count(); i++)
8756 {
8757 918 sprite *s = Lwpns.spr(i);
8758
8759
2/2
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 451 times.
918 if(s->id==wHookshot)
8760 {
8761
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 388 times.
451 if (abs((s->y) - y) >= 1)
8762 {
8763
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 38 times.
63 if((s->y)>y)
8764 {
8765 38 y+=4;
8766
8767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(Lwpns.idFirst(wHSHandle)!=-1)
8768 {
8769 38 t->y+=4;
8770 38 }
8771
8772 38 hs_starty+=4;
8773 38 }
8774
8775
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 25 times.
63 if((s->y)<y)
8776 {
8777 25 y-=4;
8778
8779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(Lwpns.idFirst(wHSHandle)!=-1)
8780 {
8781 25 t->y-=4;
8782 25 }
8783
8784 25 hs_starty-=4;
8785 25 }
8786 63 }
8787 else
8788 {
8789 388 y = (s->y);
8790 }
8791
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 63 times.
451 if (abs((s->x) - x) >= 1)
8792 {
8793
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 246 times.
388 if((s->x)>x)
8794 {
8795 246 x+=4;
8796
8797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246 times.
246 if(Lwpns.idFirst(wHSHandle)!=-1)
8798 {
8799 246 t->x+=4;
8800 246 }
8801
8802 246 hs_startx+=4;
8803 246 }
8804
8805
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 142 times.
388 if((s->x)<x)
8806 {
8807 142 x-=4;
8808
8809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if(Lwpns.idFirst(wHSHandle)!=-1)
8810 {
8811 142 t->x-=4;
8812 142 }
8813
8814 142 hs_startx-=4;
8815 142 }
8816 388 }
8817 else
8818 {
8819 63 x = (s->x);
8820 }
8821 451 }
8822 918 }
8823 }
8824 511 }
8825 1805 }
8826 else
8827 {
8828 75 Lwpns.del(Lwpns.idFirst(wHSHandle));
8829 75 reset_hookshot();
8830 }
8831
8832
1/2
✓ Branch 0 taken 1880 times.
✗ Branch 1 not taken.
1880 if(hs_fix)
8833 {
8834 if(dir==up)
8835 {
8836 y=int32_t(y+7)&0xF0;
8837 }
8838
8839 if(dir==down)
8840 {
8841 y=int32_t(y+7)&0xF0;
8842 }
8843
8844 if(dir==left)
8845 {
8846 x=int32_t(x+7)&0xF0;
8847 }
8848
8849 if(dir==right)
8850 {
8851 x=int32_t(x+7)&0xF0;
8852 }
8853
8854 hs_fix=false;
8855 }
8856
8857 1880 }
8858
8859
2/2
✓ Branch 0 taken 319621 times.
✓ Branch 1 taken 4832892 times.
5152513 if(!get_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP))
8860 {
8861
2/2
✓ Branch 0 taken 2638 times.
✓ Branch 1 taken 4830254 times.
4832892 if(DrunkrLbtn())
8862 2638 selectNextBWpn(SEL_LEFT);
8863
2/2
✓ Branch 0 taken 4827422 times.
✓ Branch 1 taken 2832 times.
4830254 else if(DrunkrRbtn())
8864 2832 selectNextBWpn(SEL_RIGHT);
8865 4832892 }
8866
4/4
✓ Branch 0 taken 329940 times.
✓ Branch 1 taken 4822573 times.
✓ Branch 2 taken 319057 times.
✓ Branch 3 taken 10883 times.
5152513 if (get_bit(quest_rules, qr_SELECTAWPN) && get_bit(quest_rules, qr_USE_EX1_EX2_INVENTORYSWAP))
8867 {
8868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10883 times.
10883 if (rEx3btn())
8869 selectNextAWpn(SEL_LEFT);
8870
2/2
✓ Branch 0 taken 10882 times.
✓ Branch 1 taken 1 times.
10883 else if (rEx4btn())
8871 1 selectNextAWpn(SEL_RIGHT);
8872 10883 }
8873
8874
2/2
✓ Branch 0 taken 5152314 times.
✓ Branch 1 taken 199 times.
5152513 if(rPbtn())
8875 {
8876
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 196 times.
199 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
8877 196 onViewMap();
8878 199 }
8879
2/2
✓ Branch 0 taken 2399752 times.
✓ Branch 1 taken 5152513 times.
7552265 for(int32_t i=0; i<Lwpns.Count(); i++)
8880 {
8881 2399752 weapon *w = ((weapon*)Lwpns.spr(i));
8882
8883
6/6
✓ Branch 0 taken 2388145 times.
✓ Branch 1 taken 11607 times.
✓ Branch 2 taken 2131971 times.
✓ Branch 3 taken 256174 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 2131898 times.
2399752 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
8884 267854 addsparkle(i);
8885 2399752 }
8886
8887
1/2
✓ Branch 0 taken 5152513 times.
✗ Branch 1 not taken.
5152513 if(Lwpns.idCount(wPhantom))
8888 {
8889 addsparkle2(pDINSFIREROCKET,pDINSFIREROCKETTRAIL);
8890 addsparkle2(pDINSFIREROCKETRETURN,pDINSFIREROCKETTRAILRETURN);
8891 addsparkle2(pNAYRUSLOVEROCKET1,pNAYRUSLOVEROCKETTRAIL1);
8892 addsparkle2(pNAYRUSLOVEROCKET2,pNAYRUSLOVEROCKETTRAIL2);
8893 addsparkle2(pNAYRUSLOVEROCKETRETURN1,pNAYRUSLOVEROCKETTRAILRETURN1);
8894 addsparkle2(pNAYRUSLOVEROCKETRETURN2,pNAYRUSLOVEROCKETTRAILRETURN2);
8895 }
8896
8897 // Pay magic cost for Byrna beams
8898
8899 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
8900
2/2
✓ Branch 0 taken 5152440 times.
✓ Branch 1 taken 73 times.
5152513 if(Lwpns.idCount(wCByrna))
8901 {
8902 73 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
8903 73 int32_t itemid = ew->parentitem;
8904
8905
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
8906 {
8907 for(int32_t i=0; i<Lwpns.Count(); i++)
8908 {
8909 weapon *w = ((weapon*)Lwpns.spr(i));
8910
8911 if(w->id==wCByrna)
8912 {
8913 w->dead=1;
8914 }
8915
8916 }
8917 //kill the sound effect for the orbits -Z 14FEB2019
8918 stop_sfx(itemsbuf[itemid].usesound);
8919 }
8920 73 else paymagiccost(itemid);
8921 73 }
8922
8923
3/4
✓ Branch 0 taken 5149245 times.
✓ Branch 1 taken 3268 times.
✓ Branch 2 taken 5149245 times.
✗ Branch 3 not taken.
5152513 if(z==0&&fakez==0)
8924 {
8925 5149245 switchblock_z = 0;
8926
1/2
✓ Branch 0 taken 5149245 times.
✗ Branch 1 not taken.
5149245 if(switchblock_offset)
8927 {
8928 switchblock_offset=false;
8929 yofs += 8;
8930 }
8931 5149245 }
8932
2/2
✓ Branch 0 taken 257641 times.
✓ Branch 1 taken 4894872 times.
5152513 if(!isSideViewHero())
8933 {
8934 4894872 int32_t tx = x.getInt()+8,
8935 4894872 ty = y.getInt()+8;//(bigHitbox?8:12);
8936
4/4
✓ Branch 0 taken 4894683 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 4894517 times.
4894872 if(!(unsigned(ty)>175 || unsigned(tx) > 255))
8937 {
8938
2/2
✓ Branch 0 taken 4894517 times.
✓ Branch 1 taken 14683551 times.
19578068 for(int32_t q = 0; q < 3; ++q)
8939 {
8940
4/4
✓ Branch 0 taken 9789034 times.
✓ Branch 1 taken 4894517 times.
✓ Branch 2 taken 1417936 times.
✓ Branch 3 taken 8371098 times.
14683551 if(q && !tmpscr2[q-1].valid) continue;
8941 6312453 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[COMBOPOS(tx,ty)]];
8942
3/4
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 6311486 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
6312453 if(cmb.type != cCSWITCHBLOCK || !(cmb.usrflags&cflag9)) continue;
8943 int32_t b = 1;
8944 if(tx&8) b <<= 2;
8945 if(ty&8) b <<= 1;
8946 b |= (b<<4); //check equivalent effect flag too
8947 if((cmb.walk&b)==b) //solid and effecting
8948 {
8949 if(z==0&&fakez==0)
8950 {
8951 if(cmb.usrflags&cflag10)
8952 {
8953 if(!switchblock_offset)
8954 {
8955 switchblock_offset=true;
8956 yofs -= 8;
8957 }
8958 }
8959 else
8960 {
8961 if(switchblock_offset)
8962 {
8963 switchblock_offset=false;
8964 yofs += 8;
8965 }
8966 }
8967 }
8968 if(cmb.attributes[2]>0 && switchblock_z>=0)
8969 {
8970 if(z==0&&fakez==0)
8971 switchblock_z = zc_max(switchblock_z,zslongToFix(cmb.attributes[2]));
8972 else if(SWITCHBLOCK_STATE < zslongToFix(cmb.attributes[2]))
8973 {
8974 switchblock_z += zslongToFix(cmb.attributes[2])-SWITCHBLOCK_STATE;
8975 }
8976 }
8977 else switchblock_z = -1;
8978 break;
8979 }
8980 }
8981 4894517 }
8982 4894872 }
8983 5152513 ClearhitHeroUIDs(); //clear them before we advance.
8984 5152513 checkhit();
8985
8986 5152513 bool forcedeath = dying_flags&DYING_FORCED;
8987 5152513 bool norev = (dying_flags&DYING_NOREV);
8988
4/6
✓ Branch 0 taken 5152513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 5152449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 64 times.
5152513 if(forcedeath || (game->get_life()<=0 && !immortal))
8989 {
8990
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(forcedeath)
8991 game->set_life(0);
8992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!norev)
8993
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 16384 times.
16448 for(size_t slot = 0; slot < 256; ++slot)
8994 {
8995
1/2
✓ Branch 0 taken 16384 times.
✗ Branch 1 not taken.
16384 if(size_t bind = game->get_bottle_slot(slot))
8996 {
8997 bottletype const* bt = &QMisc.bottle_types[bind-1];
8998 if(!(bt->flags&BTFLAG_AUTOONDEATH))
8999 continue;
9000 word toFill[3] = { 0 };
9001 for(size_t q = 0; q < 3; ++q)
9002 {
9003 char c = bt->counter[q];
9004 if(c > -1)
9005 {
9006 if(bt->flags & (1<<q))
9007 {
9008 toFill[q] = (bt->amount[q]==100)
9009 ? game->get_maxcounter(c)
9010 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
9011 }
9012 else toFill[q] = bt->amount[q];
9013 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
9014 {
9015 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
9016 }
9017 }
9018 }
9019 if(bt->flags & BTFLAG_CURESWJINX)
9020 {
9021 swordclk = 0;
9022 verifyAWpn();
9023 }
9024 if(bt->flags & BTFLAG_CUREITJINX)
9025 itemclk = 0;
9026 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
9027 {
9028 int32_t itemid = find_bottle_for_slot(slot,true);
9029 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
9030 if(itemid > -1)
9031 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
9032 for(size_t q = 0; q < 20; ++q)
9033 do_death_refill_waitframe();
9034 double inc = max/60.0; //1 second
9035 double xtra[3]{ 0 };
9036 for(size_t q = 0; q < 60; ++q)
9037 {
9038 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
9039 sfx(QMisc.miscsfx[sfxREFILL]);
9040 for(size_t j = 0; j < 3; ++j)
9041 {
9042 xtra[j] += inc;
9043 word f = floor(xtra[j]);
9044 xtra[j] -= f;
9045 if(toFill[j] > f)
9046 {
9047 toFill[j] -= f;
9048 game->change_counter(f,bt->counter[j]);
9049 }
9050 else if(toFill[j])
9051 {
9052 game->change_counter(toFill[j],bt->counter[j]);
9053 toFill[j] = 0;
9054 }
9055 }
9056 do_death_refill_waitframe();
9057 }
9058 for(size_t j = 0; j < 3; ++j)
9059 {
9060 if(toFill[j])
9061 {
9062 game->change_counter(toFill[j],bt->counter[j]);
9063 toFill[j] = 0;
9064 }
9065 }
9066 for(size_t q = 0; q < 20; ++q)
9067 do_death_refill_waitframe();
9068 }
9069 game->set_bottle_slot(slot,bt->next_type);
9070 if(game->get_life() > 0)
9071 {
9072 dying_flags = 0;
9073 forcedeath = false;
9074 break; //Revived! Stop drinking things...
9075 }
9076 }
9077 16448 }
9078
9079
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 52 times.
64 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9080 {
9081
3/6
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
12 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9082 {
9083 // So scripts can have one frame to handle hp zero events
9084
3/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11 times.
12 if(norev || false == (last_hurrah = !last_hurrah))
9085 {
9086 1 dying_flags = 0;
9087 1 drunkclk=0;
9088 1 lstunclock = 0;
9089 1 is_conveyor_stunned = 0;
9090 1 FFCore.setHeroAction(dying);
9091 1 FFCore.deallocateAllArrays(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME);
9092 1 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE);
9093 1 ALLOFF(true,true);
9094 1 GameFlags |= GAMEFLAG_NO_F6;
9095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!debug_enabled)
9096 {
9097 1 Paused=false;
9098 1 }
9099
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9100 {
9101 FFCore.runOnDeathEngine();
9102 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9103 }
9104 1 Playing = false;
9105 1 heroDeathAnimation();
9106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_bit(quest_rules,qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9107 {
9108 1 Playing = true;
9109 1 FFCore.runOnDeathEngine();
9110 1 FFCore.deallocateAllArrays(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH);
9111 1 Playing = false;
9112 1 }
9113 1 GameFlags &= ~GAMEFLAG_NO_F6;
9114 1 ALLOFF(true,true);
9115 1 return true;
9116 }
9117 11 }
9118 11 }
9119 else //2.50.x
9120 {
9121 // So scripts can have one frame to handle hp zero events
9122
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 26 times.
52 if(false == (last_hurrah = !last_hurrah))
9123 {
9124 26 drunkclk=0;
9125 26 heroDeathAnimation();
9126
9127 26 return true;
9128 }
9129 }
9130 37 }
9131 5152449 else last_hurrah=false;
9132
9133
2/2
✓ Branch 0 taken 27064 times.
✓ Branch 1 taken 5125422 times.
5152486 if(swordclk>0)
9134 {
9135 27064 --swordclk;
9136
2/2
✓ Branch 0 taken 26939 times.
✓ Branch 1 taken 125 times.
27064 if(!swordclk) verifyAWpn();
9137 27064 }
9138
2/2
✓ Branch 0 taken 4058 times.
✓ Branch 1 taken 5148428 times.
5152486 if(itemclk>0)
9139 4058 --itemclk;
9140
9141
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 5152194 times.
5152486 if(inwallm)
9142 {
9143 292 attackclk=0;
9144 292 herostep();
9145
9146
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 3 times.
292 if(CarryHero()==false)
9147 3 restart_level();
9148
9149 292 solid_update(false);
9150 292 return false;
9151 }
9152
9153
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5152193 times.
5152194 if(ewind_restart)
9154 {
9155 1 attackclk=0;
9156 1 restart_level();
9157 1 xofs=0;
9158 1 action=none; FFCore.setHeroAction(none);
9159 1 ewind_restart=false;
9160 1 solid_update(false);
9161 1 return false;
9162 }
9163
9164
2/2
✓ Branch 0 taken 5147477 times.
✓ Branch 1 taken 4716 times.
5152193 if(hopclk)
9165 {
9166 4716 action=hopping; FFCore.setHeroAction(hopping);
9167 4716 }
9168
2/2
✓ Branch 0 taken 5151983 times.
✓ Branch 1 taken 210 times.
5152193 if(fallclk)
9169 {
9170 210 action=falling; FFCore.setHeroAction(falling);
9171 210 }
9172
9173 5152193 handle_passive_buttons();
9174
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 5152073 times.
5152193 if(liftclk)
9175 {
9176
1/2
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
120 if(lift_wpn)
9177 {
9178 120 action=lifting; FFCore.setHeroAction(lifting);
9179 120 }
9180 else
9181 {
9182 liftclk = 0;
9183 tliftclk = 0;
9184 }
9185 120 }
9186
2/2
✓ Branch 0 taken 5151759 times.
✓ Branch 1 taken 314 times.
5152073 else if(lift_wpn)
9187 {
9188 314 handle_lift(false);
9189 314 }
9190
9191
9192 // get user input or do other animation
9193 5152193 freeze_guys=false; // reset this flag, set it again if holding
9194
9195
14/16
✓ Branch 0 taken 5118531 times.
✓ Branch 1 taken 33662 times.
✓ Branch 2 taken 5107607 times.
✓ Branch 3 taken 10924 times.
✓ Branch 4 taken 5106957 times.
✓ Branch 5 taken 650 times.
✓ Branch 6 taken 5106827 times.
✓ Branch 7 taken 130 times.
✓ Branch 8 taken 5106827 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5106827 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5091883 times.
✓ Branch 13 taken 14944 times.
✓ Branch 14 taken 21 times.
✓ Branch 15 taken 5091862 times.
5152193 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9196 {
9197 21 holdclk=0;
9198 21 }
9199
9200 5152193 active_shield_id = refreshActiveShield();
9201 5152193 bool sh = active_shield_id > -1;
9202 5152193 itemdata const& shield = itemsbuf[active_shield_id];
9203 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9204 5152193 shield_forcedir = -1;
9205
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5152193 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5152193 if(sh && action != rafting && (shield.flags & ITEM_FLAG11)) //Lock Dir
9206 {
9207 shield_forcedir = dir;
9208 }
9209
1/2
✓ Branch 0 taken 5152193 times.
✗ Branch 1 not taken.
5152193 if(sh != shield_active) //Toggle active shield on/off
9210 {
9211 shield_active = sh;
9212 if(sh) //Toggle active shield on
9213 {
9214 sfx(shield.usesound2); //'Activate' sfx
9215 }
9216 }
9217
9218 5152193 bool isthissolid = false;
9219
11/12
✓ Branch 0 taken 56761 times.
✓ Branch 1 taken 780 times.
✓ Branch 2 taken 704 times.
✓ Branch 3 taken 62732 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 44586 times.
✓ Branch 6 taken 4936405 times.
✓ Branch 7 taken 39459 times.
✓ Branch 8 taken 210 times.
✓ Branch 9 taken 4716 times.
✓ Branch 10 taken 5720 times.
✓ Branch 11 taken 120 times.
5152193 switch(action)
9220 {
9221 case gothit:
9222
2/2
✓ Branch 0 taken 1289 times.
✓ Branch 1 taken 38170 times.
39459 if(attackclk)
9223
2/2
✓ Branch 0 taken 1125 times.
✓ Branch 1 taken 164 times.
1453 if(!doattack())
9224 {
9225 164 attackclk=spins=0;
9226 164 tapping=false;
9227 164 }
9228
9229 39459 break;
9230
9231 case drowning:
9232 case lavadrowning:
9233 case sidedrowning:
9234 {
9235 704 herostep(); // maybe this line should be elsewhere?
9236
9237 //!DROWN
9238 // Helpful comment to find drowning -Dimi
9239
9240 704 drop_liftwpn();
9241
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 11 times.
704 if(--drownclk==0)
9242 {
9243 11 action=none; FFCore.setHeroAction(none);
9244 11 int32_t water = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9245 11 int32_t damage = combobuf[water].attributes[0]/10000L;
9246 //if (damage == 0 && !(combobuf[water].usrflags&cflag7)) damage = (game->get_hp_per_heart()/4);
9247 11 drownCombo = 0;
9248
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (combobuf[water].type != cWATER) damage = 4;
9249 11 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9250 11 go_respawn_point();
9251 11 hclk=48;
9252 11 }
9253
9254 704 break;
9255 }
9256 case falling:
9257 {
9258 210 herostep();
9259 210 pitfall();
9260 210 break;
9261 }
9262 case freeze:
9263 case sideswimfreeze:
9264 case scrolling:
9265 62732 break;
9266
9267 case casting:
9268 case sideswimcasting:
9269 {
9270 if(magicitem==-1)
9271 {
9272 action=none; FFCore.setHeroAction(none);
9273 }
9274
9275 break;
9276 }
9277 case landhold1:
9278 case landhold2:
9279 {
9280
2/2
✓ Branch 0 taken 343 times.
✓ Branch 1 taken 44243 times.
44586 if(--holdclk <= 0)
9281 {
9282 //restart music
9283
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 28 times.
343 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9284 28 playLevelMusic();
9285
9286 343 action=none; FFCore.setHeroAction(none);
9287 343 post_item_collect();
9288 343 }
9289 else
9290 44243 freeze_guys=true;
9291
9292 44586 break;
9293 }
9294 case waterhold1:
9295 case waterhold2:
9296 case sidewaterhold1:
9297 case sidewaterhold2:
9298 {
9299 780 diveclk=0;
9300
9301
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 774 times.
780 if(--holdclk <= 0)
9302 {
9303 //restart music
9304
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9305 playLevelMusic();
9306
9307 6 SetSwim();
9308 6 post_item_collect();
9309 6 }
9310 else
9311 774 freeze_guys=true;
9312
9313 780 break;
9314 }
9315 case hopping:
9316 {
9317
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4716 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4716 if(DRIEDLAKE)
9318 {
9319 action=none; FFCore.setHeroAction(none);
9320 hopclk = 0;
9321 diveclk = 0;
9322 break;
9323 }
9324
9325 4716 do_hopping();
9326 4716 break;
9327 }
9328 case inwind:
9329 {
9330 5720 int32_t i=Lwpns.idFirst(wWind);
9331
9332
2/2
✓ Branch 0 taken 5643 times.
✓ Branch 1 taken 77 times.
5720 if(i<0)
9333 {
9334 77 bool exit=false;
9335
9336
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 39 times.
77 if(whirlwind==255)
9337 {
9338 38 exit=true;
9339 38 }
9340
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39 else if(y<=0 && dir==up) y=-1;
9341
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39 else if(y>=160 && dir==down) y=161;
9342
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39 else if(x<=0 && dir==left) x=-1;
9343
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
39 else if(x>=240 && dir==right) x=241;
9344 else exit=true;
9345
9346
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
77 if(exit)
9347 {
9348 38 action=none; FFCore.setHeroAction(none);
9349 38 xofs=0;
9350 38 whirlwind=0;
9351 38 lstep=0;
9352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if ( dontdraw < 2 ) dontdraw=0;
9353 38 set_respawn_point();
9354 38 }
9355 77 }
9356 /*
9357 else if (((weapon*)Lwpns.spr(i))->dead==1)
9358 {
9359 whirlwind=255;
9360 }
9361 */
9362 else
9363 {
9364 5643 x=Lwpns.spr(i)->x;
9365 5643 y=Lwpns.spr(i)->y;
9366 5643 dir=Lwpns.spr(i)->dir;
9367 }
9368 }
9369 5720 break;
9370 case lifting:
9371 120 handle_lift();
9372 120 break;
9373
9374 case sideswimming:
9375 case sideswimattacking:
9376 case sideswimhit:
9377 case swimhit:
9378 case swimming:
9379 {
9380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56761 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
56761 if(DRIEDLAKE)
9381 {
9382 action=none; FFCore.setHeroAction(none);
9383 hopclk=0;
9384 break;
9385 }
9386
9387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56761 times.
56761 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9388
9389
4/4
✓ Branch 0 taken 28349 times.
✓ Branch 1 taken 28412 times.
✓ Branch 2 taken 224 times.
✓ Branch 3 taken 28125 times.
56761 if((frame&1) && !shouldbreak)
9390 28125 herostep();
9391
9392
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 56761 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56761 times.
✓ Branch 4 taken 2149 times.
✓ Branch 5 taken 54612 times.
58910 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9393
4/6
✓ Branch 0 taken 54612 times.
✓ Branch 1 taken 2149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2149 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2149 times.
56761 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
9394
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2149 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2149 times.
2149 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
9395
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2149 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2149 times.
56761 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
9396
4/4
✓ Branch 0 taken 55494 times.
✓ Branch 1 taken 1267 times.
✓ Branch 2 taken 55494 times.
✓ Branch 3 taken 1267 times.
56761 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9397 {
9398
4/4
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1255 times.
✓ Branch 3 taken 1 times.
2523 if(!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+9), currmap, currscr, -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+4,y.getInt()+15), currmap, currscr, -1, x.getInt()+4,y.getInt()+15, true, false)
9399
4/4
✓ Branch 0 taken 1262 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1256 times.
✓ Branch 3 taken 6 times.
1264 || !iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+9), currmap, currscr, -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex(MAPCOMBO(x.getInt()+11,y.getInt()+15), currmap, currscr, -1, x.getInt()+11,y.getInt()+15, true, false))
9400 {
9401 12 hopclk=0;
9402 12 diveclk=0;
9403
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9404 else {action=attacking; FFCore.setHeroAction(attacking);}
9405 12 hopdir=-1;
9406 12 }
9407 1267 }
9408
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 56304 times.
56761 if (shouldbreak) break;
9409
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 56292 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
56304 if (action == swimming || action == sideswimming || action == sideswimattacking)
9410 {
9411 56292 int32_t watercheck = iswaterex(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), currmap, currscr, -1, x.getInt()+7.5,y.getInt()+12, true, false);
9412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56292 times.
56292 if (combobuf[watercheck].usrflags&cflag2)
9413 {
9414 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9415 {
9416 onpassivedmg = true;
9417 if (damageovertimeclk == 0)
9418 {
9419 int32_t curhp = game->get_life();
9420 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9421 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9422 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9423 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9424 {
9425 hclk = 48;
9426 hitdir = -1;
9427 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9428 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9429 }
9430 }
9431 if (combobuf[watercheck].attribytes[1] > 0)
9432 {
9433 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9434 else --damageovertimeclk;
9435 }
9436 else damageovertimeclk = 0;
9437 }
9438 else damageovertimeclk = 0;
9439 }
9440 56292 else damageovertimeclk = 0;
9441 //combobuf[watercheck].attributes[0]
9442 56292 }
9443
9444 56304 }
9445 [[fallthrough]];
9446 default:
9447 4992709 movehero(); // call the main movement routine
9448 4992709 }
9449
9450
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5152193 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5152193 if(shield_forcedir > -1 && action != rafting)
9451 dir = shield_forcedir;
9452
9453
2/2
✓ Branch 0 taken 5127017 times.
✓ Branch 1 taken 25176 times.
5152193 if(!get_bit(quest_rules,qr_OLD_RESPAWN_POINTS))
9454 25176 set_respawn_point(false); //Keep the 'last safe location' updated!
9455
9456 // check for ladder removal
9457
2/2
✓ Branch 0 taken 658492 times.
✓ Branch 1 taken 4493701 times.
5152193 if(diagonalMovement)
9458 {
9459
2/2
✓ Branch 0 taken 658456 times.
✓ Branch 1 taken 36 times.
658492 if(ladderx+laddery)
9460 {
9461
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(ladderdir==up)
9462 {
9463 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
9464 {
9465 reset_ladder();
9466 }
9467 }
9468 else
9469 {
9470
9/10
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 33 times.
36 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
9471 {
9472 3 reset_ladder();
9473 3 }
9474 }
9475 36 }
9476 658492 }
9477 else
9478 {
9479
4/4
✓ Branch 0 taken 178022 times.
✓ Branch 1 taken 4315679 times.
✓ Branch 2 taken 82132 times.
✓ Branch 3 taken 95890 times.
4493701 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
9480 {
9481 4397811 reset_ladder();
9482 4397811 }
9483 }
9484
9485
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 5151666 times.
5152193 if(ilswim)
9486 527 landswim++;
9487 5151666 else landswim=0;
9488
9489
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5152193 times.
5152193 if(hopclk!=0xFF) ilswim=false;
9490
9491
3/4
✓ Branch 0 taken 10207 times.
✓ Branch 1 taken 5141986 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10207 times.
5152193 if((!loaded_guys) && (frame - newscr_clk >= 1))
9492 {
9493
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10201 times.
10207 if(tmpscr->room==rGANON)
9494 {
9495 6 ganon_intro();
9496 6 }
9497 else
9498 {
9499 10201 loadguys();
9500 }
9501 10207 }
9502
9503
2/2
✓ Branch 0 taken 10615 times.
✓ Branch 1 taken 5141578 times.
5152193 if(frame - newscr_clk >= 2)
9504 {
9505 5141578 loadenemies();
9506 5141578 }
9507
9508 // check lots of other things
9509 5152193 checkscroll();
9510
9511
6/8
✓ Branch 0 taken 5146512 times.
✓ Branch 1 taken 5681 times.
✓ Branch 2 taken 5145819 times.
✓ Branch 3 taken 693 times.
✓ Branch 4 taken 5145819 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5145819 times.
5152193 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
9512 {
9513 5145819 checkspecial();
9514 5145819 checkitems();
9515 5145819 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
9516
2/2
✓ Branch 0 taken 25614 times.
✓ Branch 1 taken 5120205 times.
5145819 if(get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
9517 {
9518 5120205 oldchecklockblock();
9519 5120205 oldcheckbosslockblock();
9520 5120205 }
9521
2/2
✓ Branch 0 taken 155281 times.
✓ Branch 1 taken 4990538 times.
5145819 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
9522 {
9523 4990538 oldcheckchest(cCHEST);
9524 4990538 oldcheckchest(cLOCKEDCHEST);
9525 4990538 oldcheckchest(cBOSSCHEST);
9526 4990538 }
9527 5145819 checkpushblock();
9528 5145819 checkswordtap();
9529
9530
2/2
✓ Branch 0 taken 1880 times.
✓ Branch 1 taken 5143939 times.
5145819 if(hookshot_frozen==false)
9531 {
9532 5143939 checkspecial2(&lsave);
9533 5143939 }
9534
9535
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5145813 times.
5145819 if(action==won)
9536 {
9537 6 return true;
9538 }
9539 5145813 }
9540
9541 // Somehow Hero was displaced from the fairy flag...
9542
3/6
✓ Branch 0 taken 14944 times.
✓ Branch 1 taken 5137243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14944 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5152187 if(fairyclk && action != freeze && action != sideswimfreeze)
9543 {
9544 fairyclk = holdclk = refill_why = 0;
9545 }
9546
9547
3/4
✓ Branch 0 taken 5152187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5150503 times.
✓ Branch 3 taken 1684 times.
5152187 if((!activated_timed_warp) && (tmpscr->timedwarptics>0))
9548 {
9549 1684 tmpscr->timedwarptics--;
9550
9551
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 7 times.
1684 if(tmpscr->timedwarptics==0)
9552 {
9553 7 activated_timed_warp=true;
9554
9555
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(tmpscr->flags4 & fTIMEDDIRECT)
9556 {
9557 3 didpit=true;
9558 3 pitx=x;
9559 3 pity=y;
9560 3 }
9561
9562 7 int32_t index2 = 0;
9563
9564
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tmpscr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
9565
9566 7 sdir = dir;
9567 7 dowarp(1,index2);
9568 7 }
9569 1684 }
9570
9571 5152187 bool awarp = false;
9572 //!DIMI: Global Combo Effects (AUTO STUFF)
9573
2/2
✓ Branch 0 taken 128047 times.
✓ Branch 1 taken 5152187 times.
5280234 for(auto& p : slopes)
9574 {
9575 128047 slope_object& s = p.second;
9576 128047 s.updateslope(); //sets old x/y poses
9577 }
9578
2/2
✓ Branch 0 taken 5152186 times.
✓ Branch 1 taken 906784886 times.
911937072 for(int32_t i=0; i<176; ++i)
9579 {
9580
2/2
✓ Branch 0 taken 4278736 times.
✓ Branch 1 taken 3639975749 times.
3644254485 for(int32_t layer=0; layer<7; ++layer)
9581 {
9582
2/2
✓ Branch 0 taken 2733190863 times.
✓ Branch 1 taken 906784886 times.
3639975749 int32_t cid = ( layer ) ? MAPCOMBOL(layer,COMBOX(i),COMBOY(i)) : MAPCOMBO(COMBOX(i),COMBOY(i));
9583 3639975749 newcombo const& cmb = combobuf[cid];
9584
9585
2/2
✓ Branch 0 taken 29951152 times.
✓ Branch 1 taken 3610024597 times.
3639975749 if(!get_bit(quest_rules,qr_AUTOCOMBO_ANY_LAYER))
9586 {
9587
2/2
✓ Branch 0 taken 902506149 times.
✓ Branch 1 taken 2707518448 times.
3610024597 if(layer > 2) break;
9588
4/4
✓ Branch 0 taken 902506149 times.
✓ Branch 1 taken 1805012299 times.
✓ Branch 2 taken 879344725 times.
✓ Branch 3 taken 23161424 times.
2707518448 if (layer == 1 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_1)) continue;
9589
4/4
✓ Branch 0 taken 902506149 times.
✓ Branch 1 taken 925667574 times.
✓ Branch 2 taken 23161424 times.
✓ Branch 3 taken 879344725 times.
1828173723 if (layer == 2 && !get_bit(quest_rules,qr_AUTOCOMBO_LAYER_2)) continue;
9590 948828998 }
9591 978780150 int32_t ind=0;
9592
9593 //AUTOMATIC TRIGGER CODE
9594
2/2
✓ Branch 0 taken 978765678 times.
✓ Branch 1 taken 14472 times.
978780150 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9595 {
9596 14472 do_trigger_combo(layer, i);
9597 14472 }
9598
9599 //AUTO WARP CODE
9600
2/2
✓ Branch 0 taken 19463 times.
✓ Branch 1 taken 978760687 times.
978780150 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9601 {
9602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 978760687 times.
978760687 if(cmb.type==cAWARPA)
9603 {
9604 awarp=true;
9605 ind=0;
9606 }
9607
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 978760686 times.
978760687 else if(cmb.type==cAWARPB)
9608 {
9609 1 awarp=true;
9610 1 ind=1;
9611 1 }
9612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 978760686 times.
978760686 else if(cmb.type==cAWARPC)
9613 {
9614 awarp=true;
9615 ind=2;
9616 }
9617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 978760686 times.
978760686 else if(cmb.type==cAWARPD)
9618 {
9619 awarp=true;
9620 ind=3;
9621 }
9622
1/2
✓ Branch 0 taken 978760686 times.
✗ Branch 1 not taken.
978760686 else if(cmb.type==cAWARPR)
9623 {
9624 awarp=true;
9625 ind=zc_oldrand()%4;
9626 }
9627 978760687 }
9628
2/2
✓ Branch 0 taken 978780149 times.
✓ Branch 1 taken 1 times.
978780150 if(awarp)
9629 {
9630
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags5&fDIRECTAWARP)
9631 {
9632 didpit=true;
9633 pitx=x;
9634 pity=y;
9635 }
9636
9637 1 sdir = dir;
9638 1 dowarp(1,ind);
9639 1 break;
9640 }
9641 978780149 }
9642
2/2
✓ Branch 0 taken 906784885 times.
✓ Branch 1 taken 1 times.
906784886 if(awarp) break;
9643 906784885 }
9644
9645 5152187 awarp=false;
9646
9647 5152187 word c = tmpscr->numFFC();
9648
2/2
✓ Branch 0 taken 5152181 times.
✓ Branch 1 taken 160734212 times.
165886393 for(word i=0; i<c; i++)
9649 {
9650 160734212 int32_t ind=0;
9651
9652 160734212 newcombo const& cmb = combobuf[tmpscr->ffcs[i].getData()];
9653
9654
1/2
✓ Branch 0 taken 160734212 times.
✗ Branch 1 not taken.
160734212 if (cmb.triggerflags[1]&combotriggerAUTOMATIC)
9655 {
9656 do_trigger_combo_ffc(i);
9657 }
9658
9659
2/2
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 160730304 times.
160734212 if(!(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
9660 {
9661
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 160730301 times.
160730304 if(cmb.type==cAWARPA)
9662 {
9663 3 awarp=true;
9664 3 ind=0;
9665 3 }
9666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160730301 times.
160730301 else if(cmb.type==cAWARPB)
9667 {
9668 awarp=true;
9669 ind=1;
9670 }
9671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160730301 times.
160730301 else if(cmb.type==cAWARPC)
9672 {
9673 awarp=true;
9674 ind=2;
9675 }
9676
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 160730298 times.
160730301 else if(cmb.type==cAWARPD)
9677 {
9678 3 awarp=true;
9679 3 ind=3;
9680 3 }
9681
1/2
✓ Branch 0 taken 160730298 times.
✗ Branch 1 not taken.
160730298 else if(cmb.type==cAWARPR)
9682 {
9683 awarp=true;
9684 ind=zc_oldrand()%4;
9685 }
9686 160730304 }
9687
9688
2/2
✓ Branch 0 taken 160734206 times.
✓ Branch 1 taken 6 times.
160734212 if(awarp)
9689 {
9690
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(tmpscr->flags5&fDIRECTAWARP)
9691 {
9692 didpit=true;
9693 pitx=x;
9694 pity=y;
9695 }
9696
9697 6 sdir = dir;
9698 6 dowarp(1,ind);
9699 6 break;
9700 }
9701 160734206 }
9702 5152187 zfix dx, dy;
9703
7/8
✓ Branch 0 taken 257633 times.
✓ Branch 1 taken 4894554 times.
✓ Branch 2 taken 129099 times.
✓ Branch 3 taken 128534 times.
✓ Branch 4 taken 2082 times.
✓ Branch 5 taken 127017 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2082 times.
5152187 if (sideview_mode() && !on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && on_sideview_solid_oldpos(x, y,old_x,old_y, false, 2) && !toogam)
9704 {
9705
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 2045 times.
2082 if (slide_slope(this, dx, dy, slopeid))
9706 {
9707 2045 onplatid = 5;
9708
3/4
✓ Branch 0 taken 780 times.
✓ Branch 1 taken 1265 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 780 times.
2045 if (dx || dy) push_move(dx, dy);
9709 2045 }
9710 2082 }
9711
2/2
✓ Branch 0 taken 5149540 times.
✓ Branch 1 taken 2647 times.
5152187 if (onplatid <= 0) slopeid = 0;
9712 2647 else --onplatid;
9713
2/2
✓ Branch 0 taken 3963906 times.
✓ Branch 1 taken 1188281 times.
5152187 bool onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9714
5/6
✓ Branch 0 taken 984 times.
✓ Branch 1 taken 5152171 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 968 times.
✓ Branch 5 taken 5152187 times.
5153155 for (auto q = 0; (check_slope(this, true) && !toogam) && q < 2; ++q)
9715 {
9716
2/4
✓ Branch 0 taken 968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 968 times.
968 if (check_slope(this, true) && !toogam)
9717 {
9718 968 slope_info const& s = get_slope(this, true).get_info();
9719 968 bool staircheck = false;
9720
4/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 63 times.
968 if (s.slope() != slopeid && slopeid) staircheck = true;
9721
2/2
✓ Branch 0 taken 931 times.
✓ Branch 1 taken 37 times.
968 if (onplatform) staircheck = true;
9722 968 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
9723
9724
4/4
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 734 times.
✓ Branch 2 taken 206 times.
✓ Branch 3 taken 28 times.
968 if (dx || dy)
9725 {
9726 940 int32_t pushret = push_move(dx,dy);
9727
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 20 times.
940 onplatform = (on_sideview_solid_oldpos(x, y,old_x,old_y, false, 1) && !Up());
9728
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 830 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 59 times.
940 if (s.slope() != slopeid && slopeid) staircheck = true;
9729
2/2
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 18 times.
940 if (onplatform) staircheck = true;
9730
4/4
✓ Branch 0 taken 908 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 882 times.
940 if(sideview_mode() && slopeid)
9731 882 onplatid = 5;
9732
1/2
✓ Branch 0 taken 940 times.
✗ Branch 1 not taken.
940 if (pushret == 1)
9733 {
9734 dx = -1;
9735 dy = 0;
9736 slope_push_int(s, this, dx, dy, staircheck);
9737 push_move(dx,dy);
9738 }
9739
2/2
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 12 times.
940 if (pushret == 2)
9740 {
9741 12 dx = 0;
9742 12 dy = -1;
9743 12 slope_push_int(s, this, dx, dy, staircheck);
9744 12 push_move(dx,dy);
9745 12 }
9746 940 }
9747 968 }
9748 968 }
9749
9750
2/2
✓ Branch 0 taken 5151982 times.
✓ Branch 1 taken 205 times.
5152187 if(ffwarp)
9751 {
9752
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 126 times.
205 if(ffpit)
9753 {
9754 126 ffpit=false;
9755 126 didpit=true;
9756 126 pitx=x;
9757 126 pity=y;
9758 126 }
9759
9760 205 ffwarp=false;
9761 205 dowarp(1,0);
9762 205 }
9763
9764 //Hero->WarpEx
9765
2/2
✓ Branch 0 taken 5152171 times.
✓ Branch 1 taken 16 times.
5152187 if ( FFCore.warpex[wexActive] )
9766 {
9767 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
9768 16 FFCore.warpex[wexActive] = 0;
9769 16 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
9770
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 16 times.
160 for ( int32_t q = 0; q < wexActive; q++ )
9771 {
9772 144 temp_warpex[q] = FFCore.warpex[q];
9773 144 FFCore.warpex[q] = 0;
9774 144 }
9775 32 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
9776 16 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
9777 16 }
9778
9779 // walk through bombed doors and fake walls
9780 5152187 bool walk=false;
9781 5152187 int32_t dtype=dBOMBED;
9782
9783
2/2
✓ Branch 0 taken 5021493 times.
✓ Branch 1 taken 130694 times.
5152187 if(pushing>=24) dtype=dWALK;
9784
9785
16/18
✓ Branch 0 taken 3001307 times.
✓ Branch 1 taken 2150880 times.
✓ Branch 2 taken 2976940 times.
✓ Branch 3 taken 24367 times.
✓ Branch 4 taken 2976940 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2972653 times.
✓ Branch 7 taken 4287 times.
✓ Branch 8 taken 2970404 times.
✓ Branch 9 taken 2249 times.
✓ Branch 10 taken 2970375 times.
✓ Branch 11 taken 29 times.
✓ Branch 12 taken 2961798 times.
✓ Branch 13 taken 8577 times.
✓ Branch 14 taken 2961798 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 69348 times.
✓ Branch 17 taken 3031146 times.
5152187 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned)
9786 {
9787
15/16
✓ Branch 0 taken 69389 times.
✓ Branch 1 taken 2961757 times.
✓ Branch 2 taken 481479 times.
✓ Branch 3 taken 2480278 times.
✓ Branch 4 taken 481364 times.
✓ Branch 5 taken 115 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 481364 times.
✓ Branch 8 taken 109 times.
✓ Branch 9 taken 6 times.
✓ Branch 10 taken 103405 times.
✓ Branch 11 taken 378074 times.
✓ Branch 12 taken 30414 times.
✓ Branch 13 taken 72991 times.
✓ Branch 14 taken 30309 times.
✓ Branch 15 taken 105 times.
3031146 if(((dtype==dBOMBED)?DrunkUp():dir==up) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y<=32 && tmpscr->door[0]==dtype)
9788 {
9789 105 walk=true;
9790 105 dir=up;
9791 105 }
9792
9793
15/16
✓ Branch 0 taken 69389 times.
✓ Branch 1 taken 2961757 times.
✓ Branch 2 taken 326793 times.
✓ Branch 3 taken 2634964 times.
✓ Branch 4 taken 396016 times.
✓ Branch 5 taken 166 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 396016 times.
✓ Branch 8 taken 74 times.
✓ Branch 9 taken 92 times.
✓ Branch 10 taken 58026 times.
✓ Branch 11 taken 338156 times.
✓ Branch 12 taken 17340 times.
✓ Branch 13 taken 40686 times.
✓ Branch 14 taken 17252 times.
✓ Branch 15 taken 88 times.
3031146 if(((dtype==dBOMBED)?DrunkDown():dir==down) && ((diagonalMovement||NO_GRIDLOCK)?x>112&&x<128:x==120) && y>=128 && tmpscr->door[1]==dtype)
9794 {
9795 88 walk=true;
9796 88 dir=down;
9797 88 }
9798
9799
10/14
✓ Branch 0 taken 69389 times.
✓ Branch 1 taken 2961757 times.
✓ Branch 2 taken 45203 times.
✓ Branch 3 taken 2916554 times.
✓ Branch 4 taken 45244 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 45244 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 20178 times.
✓ Branch 11 taken 25066 times.
✓ Branch 12 taken 20102 times.
✓ Branch 13 taken 76 times.
3031146 if(((dtype==dBOMBED)?DrunkLeft():dir==left) && x<=32 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[2]==dtype)
9800 {
9801 76 walk=true;
9802 76 dir=left;
9803 76 }
9804
9805
10/14
✓ Branch 0 taken 2892409 times.
✓ Branch 1 taken 69389 times.
✓ Branch 2 taken 42386 times.
✓ Branch 3 taken 2850023 times.
✓ Branch 4 taken 56465 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 56465 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 27524 times.
✓ Branch 11 taken 28941 times.
✓ Branch 12 taken 27432 times.
✓ Branch 13 taken 92 times.
2961798 if(((dtype==dBOMBED)?DrunkRight():dir==right) && x>=208 && ((diagonalMovement||NO_GRIDLOCK)?y>72&&y<88:y==80) && tmpscr->door[3]==dtype)
9806 {
9807 92 walk=true;
9808 92 dir=right;
9809 92 }
9810 2906488 }
9811
9812
2/2
✓ Branch 0 taken 5165864 times.
✓ Branch 1 taken 361 times.
5166225 if(walk)
9813 {
9814 361 hclk=0;
9815 361 drawguys=false;
9816
9817
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 127 times.
361 if(dtype==dWALK)
9818 {
9819 127 sfx(tmpscr->secretsfx);
9820 127 }
9821
9822 361 action=none; FFCore.setHeroAction(none);
9823 361 attackclk = 0;
9824 361 stepforward(29, true);
9825 361 action=scrolling; FFCore.setHeroAction(scrolling);
9826 361 pushing=false;
9827 361 }
9828
9829
4/6
✓ Branch 0 taken 74332 times.
✓ Branch 1 taken 5091893 times.
✓ Branch 2 taken 74332 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 74332 times.
5166225 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
9830 {
9831
1/2
✓ Branch 0 taken 74332 times.
✗ Branch 1 not taken.
74332 if(heart_beep)
9832 {
9833 74332 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9834 74332 }
9835 else
9836 {
9837 if ( heart_beep_timer == -1 )
9838 {
9839 heart_beep_timer = 70;
9840 }
9841
9842 if ( heart_beep_timer > 0 )
9843 {
9844 --heart_beep_timer;
9845 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
9846 }
9847 else
9848 {
9849 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9850 }
9851 }
9852 74332 }
9853 else
9854 {
9855
2/2
✓ Branch 0 taken 14038 times.
✓ Branch 1 taken 5077855 times.
5091893 if ( heart_beep_timer > -2 )
9856 {
9857 5077855 heart_beep_timer = -1;
9858 5077855 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
9859 5077855 }
9860 }
9861
9862
2/2
✓ Branch 0 taken 5165533 times.
✓ Branch 1 taken 692 times.
5166225 if(rSbtn())
9863 {
9864 692 int32_t tmp_subscr_clk = frame;
9865
9866 692 int32_t save_type = 0;
9867
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 684 times.
✗ Branch 3 not taken.
692 switch(lsave)
9868 {
9869 case 0:
9870 {
9871
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 643 times.
684 if( FFCore.runActiveSubscreenScriptEngine() )
9872 {
9873 41 break;
9874 }
9875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 643 times.
643 else if ( !stopSubscreenFalling() )
9876 {
9877 643 conveyclk=3;
9878 643 dosubscr(&QMisc);
9879 643 newscr_clk += frame - tmp_subscr_clk;
9880 643 }
9881 643 break;
9882 }
9883
9884
9885 case 2:
9886 save_type = 1;
9887 [[fallthrough]];
9888 case 1:
9889
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
9890 7 trigger_save(combobuf[last_savepoint_id]);
9891 else save_game((tmpscr->flags4&fSAVEROOM) != 0, save_type); //sanity?
9892 7 break;
9893 }
9894 692 }
9895
9896
2/2
✓ Branch 0 taken 297335 times.
✓ Branch 1 taken 4868888 times.
5166223 if (!checkstab() )
9897 {
9898 /*
9899 for(int32_t q=0; q<176; q++)
9900 {
9901 set_bit(screengrid,q,0);
9902 }
9903
9904 for(int32_t q=0; q<MAXFFCS; q++)
9905 set_bit(ffcgrid, q, 0);
9906 */
9907 4868888 }
9908
9909 5166223 check_conveyor();
9910 5166223 PhantomsCleanup();
9911 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
9912
2/2
✓ Branch 0 taken 5156947 times.
✓ Branch 1 taken 9276 times.
5166223 if(attack==wHammer)
9913 {
9914
5/8
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 9181 times.
✓ Branch 2 taken 95 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 95 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 95 times.
9276 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
9915 {
9916
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 44 times.
95 switch(dir) //Hero's dir
9917 {
9918 case up:
9919
5/10
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27 times.
✗ Branch 9 not taken.
27 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
9920 27 break;
9921
9922 case down:
9923
5/10
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
18 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
9924 18 break;
9925
9926 case left:
9927
5/10
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
6 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
9928 6 break;
9929
9930 case right:
9931
5/10
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 44 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 44 times.
✗ Branch 9 not taken.
44 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
9932 44 break;
9933 }
9934
9935 95 }
9936 9276 }
9937
9938 5166223 handleSpotlights();
9939
9940
2/2
✓ Branch 0 taken 5166004 times.
✓ Branch 1 taken 219 times.
5166223 if(getOnSideviewLadder())
9941 {
9942
5/8
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 214 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 214 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 214 times.
219 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
9943 {
9944 5 setOnSideviewLadder(false);
9945 5 }
9946
4/8
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 174 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 40 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
214 else if(CANFORCEFACEUP)
9947 {
9948 40 setDir(up);
9949 40 }
9950 219 }
9951
2/2
✓ Branch 0 taken 4952465 times.
✓ Branch 1 taken 213758 times.
5166223 if (justmoved > 0) --justmoved;
9952
9953 5166223 return false;
9954 5166549 }
9955
9956 6470 bool HeroClass::push_pixel(zfix dx, zfix dy)
9957 {
9958
2/4
✓ Branch 0 taken 6470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6470 times.
✗ Branch 3 not taken.
6470 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
9959
3/4
✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 3014 times.
✓ Branch 2 taken 3456 times.
✗ Branch 3 not taken.
6470 if(dx && dy)
9960 {
9961 bool r = push_pixel(0,dy);
9962 bool r2 = push_pixel(dx,0);
9963 return r && r2;
9964 }
9965
2/2
✓ Branch 0 taken 3091 times.
✓ Branch 1 taken 3379 times.
6470 if(dx < 0)
9966 {
9967
1/2
✓ Branch 0 taken 3091 times.
✗ Branch 1 not taken.
6182 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
9968
1/2
✓ Branch 0 taken 3091 times.
✗ Branch 1 not taken.
3091 || solpush_walkflag(x+dx,y+8,1,this)
9969
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3091 times.
✓ Branch 2 taken 2680 times.
✓ Branch 3 taken 411 times.
3091 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
9970 {
9971 3091 x += dx;
9972 3091 return true;
9973 }
9974 return false;
9975 }
9976
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 3014 times.
3379 else if(dx > 0)
9977 {
9978
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
730 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
9979
1/2
✓ Branch 0 taken 365 times.
✗ Branch 1 not taken.
365 || solpush_walkflag(x+15+dx,y+8,1,this)
9980
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 365 times.
✓ Branch 2 taken 218 times.
✓ Branch 3 taken 147 times.
365 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
9981 {
9982 365 x += dx;
9983 365 return true;
9984 }
9985 return false;
9986 }
9987
2/2
✓ Branch 0 taken 1757 times.
✓ Branch 1 taken 1257 times.
3014 else if(dy < 0)
9988 {
9989
1/2
✓ Branch 0 taken 1757 times.
✗ Branch 1 not taken.
3514 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
9990
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1757 times.
✓ Branch 2 taken 1623 times.
✓ Branch 3 taken 134 times.
1757 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
9991 {
9992 1757 y += dy;
9993 1757 return true;
9994 }
9995 return false;
9996 }
9997
1/2
✓ Branch 0 taken 1257 times.
✗ Branch 1 not taken.
1257 else if(dy > 0)
9998 {
9999
2/2
✓ Branch 0 taken 1220 times.
✓ Branch 1 taken 37 times.
2494 if(!(solpush_walkflag(x,y+15+dy,2,this)
10000
4/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1237 times.
✓ Branch 2 taken 224 times.
✓ Branch 3 taken 1013 times.
1257 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
10001 {
10002 1220 y += dy;
10003 1220 return true;
10004 }
10005 37 return false;
10006 }
10007 return false;
10008 6470 }
10009 3407 int32_t HeroClass::push_move(zfix dx, zfix dy)
10010 {
10011 3407 int32_t ret = 0;
10012
4/4
✓ Branch 0 taken 3456 times.
✓ Branch 1 taken 4259 times.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 4308 times.
7715 while(dx || dy)
10013 {
10014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4308 times.
4308 if(check_pitslide() != -1)
10015 break;
10016
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 3014 times.
4308 if(dy)
10017 {
10018
2/2
✓ Branch 0 taken 2128 times.
✓ Branch 1 taken 886 times.
3014 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
10019 3014 dy -= cy;
10020
2/2
✓ Branch 0 taken 2977 times.
✓ Branch 1 taken 37 times.
3014 if(!push_pixel(0,cy))
10021 {
10022 37 dy = 0;
10023 37 ret |= 2;
10024 37 }
10025 3014 }
10026
2/2
✓ Branch 0 taken 852 times.
✓ Branch 1 taken 3456 times.
4308 if(dx)
10027 {
10028
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 2012 times.
3456 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
10029 3456 dx -= cx;
10030
1/2
✓ Branch 0 taken 3456 times.
✗ Branch 1 not taken.
3456 if(!push_pixel(cx,0))
10031 {
10032 dx = 0;
10033 ret |= 1;
10034 }
10035 3456 }
10036 }
10037 3407 return ret;
10038 }
10039
10040 5152479 bool HeroClass::setSolid(bool set)
10041 {
10042
1/2
✓ Branch 0 taken 5152479 times.
✗ Branch 1 not taken.
5152479 bool actual = set && !toogam; //not solid when noclipping
10043 5152479 bool ret = solid_object::setSolid(actual);
10044 5152479 solid = set;
10045 5152479 return ret;
10046 }
10047
10048 13071 void HeroClass::solid_push(solid_object* obj)
10049 {
10050
1/2
✓ Branch 0 taken 13071 times.
✗ Branch 1 not taken.
13071 if(obj == this) return; //can't push self
10051
10052 13071 zfix dx, dy;
10053 13071 int32_t hdir = -1;
10054 13071 solid_push_int(obj,dx,dy,hdir);
10055
10056
4/4
✓ Branch 0 taken 12146 times.
✓ Branch 1 taken 925 times.
✓ Branch 2 taken 11881 times.
✓ Branch 3 taken 265 times.
13071 if(!dx && !dy) return;
10057
10058 1190 obj->doContactDamage(hdir);
10059
10060 1190 bool t = obj->getTempNonsolid();
10061 1190 obj->setTempNonsolid(true);
10062
10063 1190 push_move(dx,dy);
10064
10065 1190 obj->setTempNonsolid(t);
10066 13071 }
10067
10068 // A routine used exclusively by startwpn,
10069 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10070 595 void HeroClass::deselectbombs(int32_t super)
10071 {
10072
6/10
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 583 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 583 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 583 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 583 times.
595 if ( get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].family == itype_bomb || itemsbuf[game->forced_bwpn].family == itype_bomb || itemsbuf[game->forced_xwpn].family == itype_bomb || itemsbuf[game->forced_ywpn].family == itype_bomb) return;
10073
2/6
✓ Branch 0 taken 583 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 583 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
583 if(getItemFamily(itemsbuf,Bwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10074 {
10075
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 583 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 583 times.
583 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10076 583 Bwpn = Bweapon(temp);
10077 583 directItemB = directItem;
10078 583 game->bwpn = temp;
10079 583 }
10080
10081 else if (getItemFamily(itemsbuf,Xwpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10082 {
10083 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->xwpn, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10084 Xwpn = Bweapon(temp);
10085 directItemX = directItem;
10086 game->xwpn = temp;
10087 }
10088 else if (getItemFamily(itemsbuf,Ywpn&0x0FFF)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10089 {
10090 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->ywpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, game->awpn);
10091 Ywpn = Bweapon(temp);
10092 directItemY = directItem;
10093 game->ywpn = temp;
10094 }
10095 else
10096 {
10097 int32_t temp = selectWpn_new(SEL_VERIFY_LEFT, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
10098 Awpn = Bweapon(temp);
10099 directItemA = directItem;
10100 game->awpn = temp;
10101 }
10102 595 }
10103
10104 int32_t potion_life=0;
10105 int32_t potion_magic=0;
10106
10107 4993353 bool HeroClass::onWater(bool drownonly)
10108 {
10109 4993353 int32_t water = 0;
10110 4993353 int32_t types[4] = {0};
10111 4993353 int32_t x1 = x+4, x2 = x+11,
10112 4993353 y1 = y+9, y2 = y+15;
10113
2/2
✓ Branch 0 taken 238144 times.
✓ Branch 1 taken 4755209 times.
4993353 if (get_bit(quest_rules, qr_SMARTER_WATER))
10114 {
10115
4/4
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 236530 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1314 times.
239461 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
10116
2/2
✓ Branch 0 taken 1439 times.
✓ Branch 1 taken 175 times.
1614 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
10117
2/2
✓ Branch 0 taken 1317 times.
✓ Branch 1 taken 122 times.
1439 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
10118 1317 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10119 238144 }
10120 else
10121 {
10122 4755209 types[0] = COMBOTYPE(x1,y1);
10123
10124
2/2
✓ Branch 0 taken 12835 times.
✓ Branch 1 taken 4742374 times.
4755209 if(MAPFFCOMBO(x1,y1))
10125 12835 types[0] = FFCOMBOTYPE(x1,y1);
10126
10127 4755209 types[1] = COMBOTYPE(x1,y2);
10128
10129
2/2
✓ Branch 0 taken 12072 times.
✓ Branch 1 taken 4743137 times.
4755209 if(MAPFFCOMBO(x1,y2))
10130 12072 types[1] = FFCOMBOTYPE(x1,y2);
10131
10132 4755209 types[2] = COMBOTYPE(x2,y1);
10133
10134
2/2
✓ Branch 0 taken 13019 times.
✓ Branch 1 taken 4742190 times.
4755209 if(MAPFFCOMBO(x2,y1))
10135 13019 types[2] = FFCOMBOTYPE(x2,y1);
10136
10137 4755209 types[3] = COMBOTYPE(x2,y2);
10138
10139
2/2
✓ Branch 0 taken 12207 times.
✓ Branch 1 taken 4743002 times.
4755209 if(MAPFFCOMBO(x2,y2))
10140 12207 types[3] = FFCOMBOTYPE(x2,y2);
10141
10142 4755209 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10143
2/2
✓ Branch 0 taken 12636 times.
✓ Branch 1 taken 4742573 times.
4755209 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10144 12636 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10145
10146
5/6
✓ Branch 0 taken 114032 times.
✓ Branch 1 taken 4641177 times.
✓ Branch 2 taken 107755 times.
✓ Branch 3 taken 6277 times.
✓ Branch 4 taken 101815 times.
✗ Branch 5 not taken.
4857024 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10147
4/4
✓ Branch 0 taken 101945 times.
✓ Branch 1 taken 5810 times.
✓ Branch 2 taken 101815 times.
✓ Branch 3 taken 130 times.
107755 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10148 101815 water = typec;
10149 }
10150
2/2
✓ Branch 0 taken 4890224 times.
✓ Branch 1 taken 103129 times.
4993353 if(water > 0)
10151 {
10152
1/2
✓ Branch 0 taken 103129 times.
✗ Branch 1 not taken.
103129 if(!drownonly) return true;
10153
4/8
✓ Branch 0 taken 57676 times.
✓ Branch 1 taken 45453 times.
✓ Branch 2 taken 57676 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57676 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
103129 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
10154 {
10155 45453 return true;
10156 }
10157 57676 }
10158 4947900 return false;
10159 4993353 }
10160
10161 bool HeroClass::mirrorBonk()
10162 {
10163 zfix tx = x, ty = y, tz = z;
10164 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10165 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10166 execute(info);
10167 bool fail = info.isUnwalkable();
10168
10169 if(!fail) //not solid, but check for water/pits...
10170 {
10171 if(onWater(true))
10172 fail = true;
10173 if(pitslide() || fallclk)
10174 fail = true;
10175 fallclk = 0;
10176 }
10177 x = tx; y = ty; z = tz;
10178 return fail;
10179 }
10180
10181 void HeroClass::doMirror(int32_t mirrorid)
10182 {
10183 if(z > 0 || fakez > 0) return; //No mirror in air
10184 if(mirrorid < 0)
10185 mirrorid = current_item_id(itype_mirror);
10186 if(mirrorid < 0) return;
10187
10188 if((tmpscr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10189 {
10190 item_error();
10191 return;
10192 }
10193 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10194 int32_t posarr[] = {COMBOPOS(x+sens,y+sens), COMBOPOS(x+sens,y+15-sens),
10195 COMBOPOS(x+15-sens,y+sens), COMBOPOS(x+15-sens,y+15-sens)};
10196 for(auto pos : posarr)
10197 {
10198 if(HASFLAG_ANY(mfNOMIRROR, pos)) //"No Mirror" flag touching the player
10199 {
10200 item_error();
10201 return;
10202 }
10203 }
10204
10205 itemdata const& mirror = itemsbuf[mirrorid];
10206 if(DMaps[currdmap].flags & dmfMIRRORCONTINUE)
10207 {
10208 paymagiccost(mirrorid);
10209 if(mirror.usesound2) sfx(mirror.usesound2);
10210
10211 doWarpEffect(mirror.misc2, true);
10212 if(mirror.flags & ITEM_FLAG2) //Act as F6->Continue
10213 {
10214 Quit = qCONT;
10215 skipcont = 1;
10216 }
10217 else //Act as Farore's Wind
10218 {
10219 int32_t nayrutemp=nayruitem;
10220 restart_level();
10221 nayruitem=nayrutemp;
10222 magicitem=-1;
10223 magiccastclk=0;
10224 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10225 }
10226 }
10227 else
10228 {
10229 int32_t destdmap = DMaps[currdmap].mirrorDMap;
10230 int32_t offscr = currscr - DMaps[currdmap].xoff;
10231 if(destdmap < 0)
10232 return;
10233 int32_t destscr = DMaps[destdmap].xoff + offscr;
10234 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10235 return;
10236 paymagiccost(mirrorid);
10237
10238 //Store some values to restore if 'warp fails'
10239 int32_t tLastEntrance = lastentrance,
10240 tLastEntranceDMap = lastentrance_dmap,
10241 tContScr = game->get_continue_scrn(),
10242 tContDMap = game->get_continue_dmap(),
10243 tPortalDMap = game->portalsrcdmap;
10244 int32_t sourcescr = currscr, sourcedmap = currdmap;
10245 zfix tx = x, ty = y, tz = z;
10246 game->portalsrcdmap = -1;
10247 action = none; FFCore.setHeroAction(none);
10248
10249 //Warp to new dmap
10250 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10251 mirror.usesound, 0, -1);
10252
10253 //Check for valid landing location
10254 if(mirrorBonk()) //Invalid landing, warp back!
10255 {
10256 action = none; FFCore.setHeroAction(none);
10257 lastentrance = tLastEntrance;
10258 lastentrance_dmap = tLastEntranceDMap;
10259 game->set_continue_scrn(tContScr);
10260 game->set_continue_dmap(tContDMap);
10261 x = tx;
10262 y = ty;
10263 z = tz;
10264 game->portalsrcdmap = tPortalDMap;
10265 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10266 mirror.usesound, 0, -1);
10267 }
10268 else if(mirror.flags & ITEM_FLAG1) //Place portal!
10269 {
10270 //Place the portal
10271 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10272 //Since it was placed after loading this screen, load the portal object now
10273 game->load_portal();
10274 //Don't immediately trigger the warp back
10275 can_mirror_portal = false;
10276
10277 //Set continue point
10278 if(currdmap != game->get_continue_dmap())
10279 {
10280 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
10281 }
10282 game->set_continue_dmap(currdmap);
10283 lastentrance_dmap = currdmap;
10284 lastentrance = game->get_continue_scrn();
10285 }
10286 }
10287 }
10288
10289 5152193 void HeroClass::handle_passive_buttons()
10290 {
10291 5152193 do_liftglove(-1,true);
10292 5152193 do_jump(-1,true);
10293 5152193 }
10294
10295 static bool did_passive_jump = false;
10296 5152260 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10297 {
10298
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 5152193 times.
5152260 if(passive) did_passive_jump = false;
10299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 else if(did_passive_jump) return false; //don't jump twice in the same frame
10300
10301
2/2
✓ Branch 0 taken 158907 times.
✓ Branch 1 taken 4993353 times.
5152260 if(nomove_action(action)) return false; //can't jump while ex. drowning
10302
2/2
✓ Branch 0 taken 45453 times.
✓ Branch 1 taken 4947900 times.
4993353 if(onWater(true)) return false; //Don't allow jumping off of water frame-perfectly...
10303
10304
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 4947833 times.
4947900 if(jumpid < 0)
10305 4947833 jumpid = current_item_id(itype_rocs,true,true);
10306
10307
2/2
✓ Branch 0 taken 4758544 times.
✓ Branch 1 taken 189356 times.
4947900 if(unsigned(jumpid) >= MAXITEMS) return false;
10308
4/4
✓ Branch 0 taken 189245 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 1411 times.
✓ Branch 3 taken 187834 times.
189356 if(inlikelike || charging) return false;
10309
1/2
✓ Branch 0 taken 187834 times.
✗ Branch 1 not taken.
187834 if(!checkitem_jinx(jumpid)) return false;
10310
10311 187834 itemdata const& itm = itemsbuf[jumpid];
10312
10313 187834 bool standing = isStanding(true);
10314
3/4
✓ Branch 0 taken 185472 times.
✓ Branch 1 taken 2362 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2362 times.
187834 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10315
4/6
✓ Branch 0 taken 187834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2362 times.
✓ Branch 3 taken 185472 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2362 times.
187834 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10316
3/4
✓ Branch 0 taken 183670 times.
✓ Branch 1 taken 1802 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 183670 times.
185472 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10317 {
10318 1802 item_error();
10319 1802 return false;
10320 }
10321
10322 183670 byte intbtn = byte(itm.misc2&0xFF);
10323
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 183609 times.
183670 if(passive)
10324 {
10325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183609 times.
183609 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10326 183609 return false; //not pressed
10327 }
10328
10329 61 paymagiccost(jumpid);
10330
10331
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(!standing)
10332 {
10333 ++extra_jump_count;
10334 fall = 0;
10335 fakefall = 0;
10336 if(hoverclk > 0)
10337 hoverclk = -hoverclk;
10338 }
10339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(itm.flags & ITEM_FLAG1)
10340 setFall(fall - itm.power);
10341 61 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
10342 61 coyotetime = 65535; //jumped, so no coyotetime
10343 61 setOnSideviewLadder(false);
10344
10345 // Reset the ladder, unless on an unwalkable combo
10346
3/10
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 61 times.
✗ Branch 9 not taken.
61 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,SWITCHBLOCK_STATE)))
10347 reset_ladder();
10348
10349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(itm.usesound)
10350 61 sfx(itm.usesound,pan(x.getInt()));
10351
10352
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(passive)
10353 {
10354 did_passive_jump = true;
10355 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10356 }
10357 61 return true;
10358 5152260 }
10359 928 void HeroClass::drop_liftwpn()
10360 {
10361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 928 times.
928 if(!lift_wpn) return;
10362
10363 handle_lift(false); //sets position properly, accounting for large weapons
10364 auto liftid = current_item_id(itype_liftglove,true,true);
10365 itemdata const& glove = itemsbuf[liftid];
10366 if(glove.flags & ITEM_FLAG1)
10367 {
10368 lift_wpn->z = 0;
10369 lift_wpn->fakez = liftheight;
10370 }
10371 else lift_wpn->z = liftheight;
10372 lift_wpn->dir = dir;
10373 lift_wpn->step = 0;
10374 lift_wpn->fakefall = 0;
10375 lift_wpn->fall = 0;
10376 if(glove.flags & ITEM_FLAG1)
10377 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10378 else
10379 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10380 Lwpns.add(lift_wpn);
10381 lift_wpn = nullptr;
10382 928 }
10383 5152193 void HeroClass::do_liftglove(int32_t liftid, bool passive)
10384 {
10385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5152193 times.
5152193 if(liftid < 0)
10386 5152193 liftid = current_item_id(itype_liftglove,true,true);
10387
2/2
✓ Branch 0 taken 10039 times.
✓ Branch 1 taken 5142154 times.
5152193 if(!can_lift(liftid)) return;
10388 10039 itemdata const& glove = itemsbuf[liftid];
10389 10039 byte intbtn = byte(glove.misc1&0xFF);
10390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10039 times.
10039 if(passive)
10391 {
10392
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 9987 times.
10039 if(!getIntBtnInput(intbtn, true, true, false, false, true))
10393 9987 return; //not pressed
10394 52 }
10395
10396 52 bool had_weapon = lift_wpn;
10397
10398
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
91 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
10399
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 2 times.
41 (checkbunny(liftid) && checkmagiccost(liftid))))
10400 {
10401 2 item_error();
10402 2 return;
10403 }
10404
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
50 if(glove.script!=0 && (item_doscript[liftid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10405 return;
10406
10407 50 bool paidmagic = had_weapon; //don't pay to throw, only to lift
10408
1/2
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
50 if(glove.script)
10409 {
10410 if(!paidmagic)
10411 {
10412 paidmagic = true;
10413 paymagiccost(liftid);
10414 }
10415
10416 ri = &(itemScriptData[liftid]);
10417 for ( int32_t q = 0; q < 1024; q++ )
10418 item_stack[liftid][q] = 0xFFFF;
10419 ri->Clear();
10420 item_doscript[liftid] = 1;
10421 itemscriptInitialised[liftid] = 0;
10422 ZScriptVersion::RunScript(SCRIPT_ITEM, glove.script, liftid);
10423
10424 bool has_weapon = lift_wpn;
10425 if(has_weapon != had_weapon) //Item action script changed the lift information
10426 {
10427 if(passive)
10428 {
10429 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10430 }
10431 return;
10432 }
10433 }
10434
10435
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 39 times.
50 if(lift_wpn)
10436 {
10437
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!paidmagic)
10438 {
10439 paidmagic = true;
10440 paymagiccost(liftid);
10441 }
10442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!liftclk)
10443 {
10444 //Throw the weapon!
10445 //hero's direction and position
10446 11 handle_lift(false); //sets position properly, accounting for large weapons
10447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(glove.flags & ITEM_FLAG1)
10448 {
10449 lift_wpn->z = 0;
10450 lift_wpn->fakez = liftheight;
10451 }
10452 11 else lift_wpn->z = liftheight;
10453 11 lift_wpn->dir = dir;
10454 //Configured throw speed in both axes
10455 11 lift_wpn->step = zfix(glove.misc2)/100;
10456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(glove.flags & ITEM_FLAG1)
10457 {
10458 lift_wpn->fakefall = -glove.misc3;
10459 lift_wpn->moveflags |= FLAG_NO_REAL_Z;
10460 }
10461 else
10462 {
10463 11 lift_wpn->fall = -glove.misc3;
10464 11 lift_wpn->moveflags |= FLAG_NO_FAKE_Z;
10465 }
10466 11 Lwpns.add(lift_wpn);
10467 11 lift_wpn = nullptr;
10468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(glove.usesound2)
10469 11 sfx(glove.usesound2,pan(int32_t(x)));
10470 11 }
10471
10472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(passive)
10473 {
10474 11 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10475 11 }
10476 11 return;
10477 }
10478
10479 //Check for a liftable combo
10480 39 zfix bx, by;
10481 39 zfix bx2, by2;
10482
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 13 times.
39 switch(dir)
10483 {
10484 case up:
10485 15 by = y + (bigHitbox ? -2 : 6);
10486 15 by2 = by;
10487 15 bx = x + 4;
10488 15 bx2 = bx + 8;
10489 15 break;
10490 case down:
10491 7 by = y + 17;
10492 7 by2 = by;
10493 7 bx = x + 4;
10494 7 bx2 = bx + 8;
10495 7 break;
10496 case left:
10497 4 by = y + (bigHitbox ? 0 : 8);
10498 4 by2 = y + 8;
10499 4 bx = x - 2;
10500 4 bx2 = x - 2;
10501 4 break;
10502 case right:
10503 13 by = y + (bigHitbox ? 0 : 8);
10504 13 by2 = y + 8;
10505 13 bx = x + 17;
10506 13 bx2 = x + 17;
10507 13 break;
10508 }
10509 39 int32_t pos = COMBOPOS_B(bx,by);
10510 39 int32_t pos2 = COMBOPOS_B(bx2,by2);
10511 39 int32_t foundpos = -1;
10512
10513 39 bool lifted = false;
10514
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 269 times.
297 for(auto lyr = 6; lyr >= 0; --lyr)
10515 {
10516 269 mapscr* scr = FFCore.tempScreens[lyr];
10517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 269 times.
269 if(pos > -1)
10518 {
10519 269 newcombo const& cmb = combobuf[scr->data[pos]];
10520
2/2
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 11 times.
269 if(cmb.liftflags & LF_LIFTABLE)
10521 {
10522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(do_lift_combo(lyr,pos,liftid))
10523 {
10524 11 lifted = true;
10525 11 break;
10526 }
10527 }
10528 258 }
10529
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 181 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
258 if(pos != pos2 && pos2 > -1)
10530 {
10531 77 newcombo const& cmb2 = combobuf[scr->data[pos2]];
10532
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(cmb2.liftflags & LF_LIFTABLE)
10533 {
10534 if(do_lift_combo(lyr,pos2,liftid))
10535 {
10536 lifted = true;
10537 break;
10538 }
10539 }
10540 77 }
10541 258 }
10542
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 28 times.
39 if(!lifted) return;
10543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!paidmagic)
10544 {
10545 11 paidmagic = true;
10546 11 paymagiccost(liftid);
10547 11 }
10548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(passive)
10549 11 getIntBtnInput(intbtn, true, true, false, false, false); //eat buttons
10550 11 return;
10551 5152193 }
10552 947 void HeroClass::handle_lift(bool dec)
10553 {
10554 947 lift_wpn->fakez = 0;
10555
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(!lift_wpn) liftclk = 0;
10556
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 218 times.
947 if(liftclk <= (dec?1:0))
10557 {
10558 729 liftclk = 0;
10559 729 tliftclk = 0;
10560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 729 times.
729 if(lift_wpn)
10561 {
10562
2/4
✓ Branch 0 taken 729 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 729 times.
729 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
10563 {
10564 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
10565 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
10566 }
10567 else
10568 {
10569 729 lift_wpn->x = x;
10570 729 lift_wpn->y = y;
10571 }
10572 729 lift_wpn->z = liftheight;
10573 729 }
10574
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 11 times.
729 if(action == lifting)
10575 {
10576 11 action = none; FFCore.setHeroAction(none);
10577 11 }
10578 729 return;
10579 }
10580
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 109 times.
218 if(dec) --liftclk;
10581 double xdist, ydist;
10582 218 double perc = (liftclk/double(tliftclk));
10583
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 60 times.
✓ Branch 4 taken 70 times.
218 switch(dir)
10584 {
10585 case up:
10586 {
10587 14 xdist = 0;
10588 14 ydist = -16;
10589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(lift_wpn->txsz > 1)
10590 {
10591 xdist = -((lift_wpn->txsz*8)-8);
10592 }
10593 14 else xdist = 0;
10594
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(lift_wpn->tysz > 1)
10595 {
10596 ydist = -(lift_wpn->tysz*16);
10597 }
10598 14 ydist *= perc;
10599 14 break;
10600 }
10601 case down:
10602 {
10603 74 xdist = 0;
10604 74 ydist = 16;
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(lift_wpn->txsz > 1)
10606 {
10607 xdist = -((lift_wpn->txsz*8)-8);
10608 }
10609 74 else xdist = 0;
10610 74 ydist *= perc;
10611 74 break;
10612 }
10613 case left:
10614 {
10615 60 xdist = -16;
10616 60 ydist = 0;
10617
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(lift_wpn->txsz > 1)
10618 {
10619 xdist = -(lift_wpn->txsz*16);
10620 }
10621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(lift_wpn->tysz > 1)
10622 {
10623 ydist = -((lift_wpn->tysz*8)-8);
10624 }
10625 60 else ydist = 0;
10626 60 xdist *= perc;
10627 60 break;
10628 }
10629 case right:
10630 {
10631 70 xdist = 16;
10632 70 ydist = 0;
10633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70 times.
70 if(lift_wpn->tysz > 1)
10634 {
10635 ydist = -((lift_wpn->tysz*8)-8);
10636 }
10637 70 else ydist = 0;
10638 70 xdist *= perc;
10639 70 break;
10640 }
10641 }
10642
10643 218 lift_wpn->x = x + xdist;
10644 218 lift_wpn->y = y + ydist;
10645 218 lift_wpn->z = liftheight*(1.0-perc);
10646 947 }
10647 5152204 bool HeroClass::can_lift(int32_t gloveid)
10648 {
10649
2/2
✓ Branch 0 taken 5141010 times.
✓ Branch 1 taken 11194 times.
5152204 if(unsigned(gloveid) >= MAXITEMS) return false;
10650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11194 times.
11194 if(lstunclock) return false;
10651
1/2
✓ Branch 0 taken 11194 times.
✗ Branch 1 not taken.
11194 if(!checkitem_jinx(gloveid)) return false;
10652 11194 itemdata const& glove = itemsbuf[gloveid];
10653
2/3
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 10050 times.
✗ Branch 2 not taken.
11194 switch(action)
10654 {
10655 case none: case walking:
10656 10050 break;
10657
10658 case swimming:
10659 if(glove.flags & ITEM_FLAG2)
10660 break;
10661 return false;
10662
10663 default:
10664 1144 return false;
10665 }
10666 10050 return true;
10667 5152204 }
10668 11 void HeroClass::lift(weapon* w, byte timer, zfix height)
10669 {
10670 11 lift_wpn = w;
10671 11 liftclk = timer;
10672 11 tliftclk = timer;
10673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(height < 0)
10674 liftheight = 0;
10675 11 else liftheight = height;
10676 11 }
10677
10678 1 void HeroClass::doSwitchHook(byte style)
10679 {
10680 1 hs_switcher = true;
10681 1 pull_hero = true;
10682 //{ Load hook weapons, set them to obey special drawing
10683 1 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
10684 1 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
10685
10686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w)
10687 1 w->switch_hooked = true;
10688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hw)
10689 1 hw->switch_hooked = true;
10690
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
10691 {
10692 5 chainlinks.spr(j)->switch_hooked = true;
10693 5 }
10694 //}
10695
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(hooked_combopos > -1)
10696 {
10697 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
10698 hooked_layerbits = 0;
10699 for(auto q = 0; q < 7; ++q)
10700 hooked_undercombos[q] = -1;
10701 uint16_t plpos = COMBOPOS(x+8,y+8);
10702 for(auto q = max_layer; q > -1; --q)
10703 {
10704 newcombo const& cmb = combobuf[FFCore.tempScreens[q]->data[hooked_combopos]];
10705 newcombo const& comb2 = combobuf[FFCore.tempScreens[q]->data[plpos]];
10706 int32_t fl1 = FFCore.tempScreens[q]->sflag[hooked_combopos],
10707 fl2 = FFCore.tempScreens[q]->sflag[plpos];
10708 bool isPush = false;
10709 if(isSwitchHookable(cmb))
10710 {
10711 if(cmb.type == cSWITCHHOOK)
10712 {
10713 uint16_t plpos = COMBOPOS(x+8,y+8);
10714 if((cmb.usrflags&cflag1) && FFCore.tempScreens[q]->data[plpos])
10715 continue; //don't swap with non-zero combo
10716 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].fam_type) < cmb.attribytes[0])
10717 continue; //too low a switchhook level
10718 hooked_layerbits |= 1<<q; //Swapping
10719 if(cmb.usrflags&cflag3)
10720 {
10721 if(cmb.usrflags&cflag6)
10722 {
10723 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10724 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10725 }
10726 else
10727 {
10728 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10729 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10730 }
10731 }
10732 else
10733 {
10734 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10735 if(cmb.usrflags&cflag7) //counts as 'pushblock'
10736 isPush = true;
10737 }
10738 }
10739 else if(isCuttableType(cmb.type))
10740 {
10741 if(isCuttableNextType(cmb.type))
10742 {
10743 hooked_undercombos[q] = FFCore.tempScreens[q]->data[hooked_combopos]+1;
10744 hooked_undercombos[q+7] = FFCore.tempScreens[q]->cset[hooked_combopos];
10745 }
10746 else
10747 {
10748 hooked_undercombos[q] = FFCore.tempScreens[q]->undercombo;
10749 hooked_undercombos[q+7] = FFCore.tempScreens[q]->undercset;
10750 }
10751 hooked_layerbits |= 1<<q; //Swapping
10752 }
10753 else
10754 {
10755 hooked_layerbits |= 1<<q; //Swapping
10756 hooked_layerbits |= 1<<(q+8); //Swapping BACK
10757 }
10758 }
10759 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
10760 {
10761 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
10762 && hasMainGuy())
10763 {
10764 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
10765 continue;
10766 }
10767 if(fl1 == mfPUSHED)
10768 {
10769 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
10770 continue;
10771 }
10772 if(!isPush) switch(fl1)
10773 {
10774 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10775 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10776 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10777 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10778 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10779 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10780 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10781 isPush = true;
10782 }
10783 if(!isPush) switch(cmb.flag)
10784 {
10785 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
10786 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
10787 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
10788 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
10789 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
10790 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
10791 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
10792 isPush = true;
10793 }
10794 if(isPush) //Check for block holes / triggers
10795 {
10796 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
10797 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
10798 {
10799 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10800 }
10801 else if(!get_bit(quest_rules, qr_BLOCKHOLE_SAME_ONLY))
10802 {
10803 auto maxLayer = get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
10804 for(auto lyr = 0; lyr < maxLayer; ++lyr)
10805 {
10806 if(lyr == q) continue;
10807 switch(FFCore.tempScreens[q]->sflag[plpos])
10808 {
10809 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10810 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10811 lyr=7;
10812 break;
10813 }
10814 switch(combobuf[FFCore.tempScreens[q]->data[plpos]].flag)
10815 {
10816 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
10817 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
10818 lyr=7;
10819 break;
10820 }
10821 }
10822 }
10823 }
10824 }
10825 }
10826 }
10827 1 switch_hooked = true;
10828 1 switchhookstyle = style;
10829
1/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1 switch(style)
10830 {
10831 default: case swPOOF:
10832 {
10833 1 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
10834
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
10835
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(x, y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_combopos > -1)
10837 decorations.add(new comboSprite((zfix)COMBOX(hooked_combopos), (zfix)COMBOY(hooked_combopos), 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object)
10839
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(switching_object->x, switching_object->y, 0, 0, QMisc.sprites[sprSWITCHPOOF]));
10840 1 break;
10841 }
10842 case swFLICKER:
10843 {
10844 switchhookmaxtime = switchhookclk = 64;
10845 break;
10846 }
10847 case swRISE:
10848 {
10849 switchhookmaxtime = switchhookclk = 64;
10850 break;
10851 }
10852 }
10853 1 }
10854
10855 24725 bool HeroClass::startwpn(int32_t itemid)
10856 {
10857
1/2
✓ Branch 0 taken 24725 times.
✗ Branch 1 not taken.
24725 if(itemid < 0) return false;
10858 24725 itemdata const& itm = itemsbuf[itemid];
10859
5/6
✓ Branch 0 taken 5879 times.
✓ Branch 1 taken 18846 times.
✓ Branch 2 taken 4713 times.
✓ Branch 3 taken 14133 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39 times.
24764 if(((dir==up && y<24) || (dir==down && y>128) ||
10860
6/6
✓ Branch 0 taken 6973 times.
✓ Branch 1 taken 7160 times.
✓ Branch 2 taken 7158 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 39 times.
✓ Branch 5 taken 24684 times.
24725 (dir==left && x<32) || (dir==right && x>208)) && !(get_bit(quest_rules,qr_ITEMSONEDGES) || inlikelike))
10861 39 return false;
10862
10863 24686 int32_t wx=x;
10864 24686 int32_t wy=y-fakez;
10865 24686 int32_t wz=z;
10866 24686 bool ret = true;
10867
10868
5/5
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5867 times.
✓ Branch 2 taken 4705 times.
✓ Branch 3 taken 6961 times.
✓ Branch 4 taken 7151 times.
24686 switch(dir)
10869 {
10870 case up:
10871 5867 wy-=16;
10872 5867 break;
10873
10874 case down:
10875 4705 wy+=16;
10876 4705 break;
10877
10878 case left:
10879 6961 wx-=16;
10880 6961 break;
10881
10882 case right:
10883 7151 wx+=16;
10884 7151 break;
10885 }
10886
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24686 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24686 if (IsSideSwim() && (itm.flags & ITEM_SIDESWIM_DISABLED)) return false;
10887
10888
15/27
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 1163 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 67 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 141 times.
✓ Branch 11 taken 581 times.
✓ Branch 12 taken 14 times.
✓ Branch 13 taken 1207 times.
✓ Branch 14 taken 12250 times.
✓ Branch 15 taken 984 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 516 times.
✓ Branch 18 taken 9 times.
✓ Branch 19 taken 7648 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
24686 switch(itm.family)
10889 {
10890 case itype_liftglove:
10891 {
10892 do_liftglove(itemid,false);
10893 dowpn = -1;
10894 ret = false;
10895 break;
10896 }
10897 case itype_potion:
10898 {
10899
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
23 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10900 {
10901 return item_error();
10902 }
10903
10904 23 paymagiccost(itemid);
10905
10906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23 if(itm.misc1 || itm.misc2)
10907 {
10908 23 refill_what=REFILL_ALL;
10909 23 refill_why=itemid;
10910 23 StartRefill(REFILL_ALL);
10911 23 potion_life = game->get_life();
10912 23 potion_magic = game->get_magic();
10913
10914 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10915 //music_pause();
10916 23 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10917
2/2
✓ Branch 0 taken 4932 times.
✓ Branch 1 taken 23 times.
4955 while(refill())
10918 {
10919 4932 do_refill_waitframe();
10920 }
10921
10922 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
10923 //music_resume();
10924 23 ret = false;
10925 23 }
10926
10927 23 break;
10928 }
10929 case itype_bottle:
10930 {
10931 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
10932 {
10933 return item_error();
10934 }
10935 if(itm.script!=0 && (item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
10936 return false;
10937
10938 size_t bind = game->get_bottle_slot(itm.misc1);
10939 bool paidmagic = false;
10940 if(itm.script)
10941 {
10942 paidmagic = true;
10943 paymagiccost(itemid);
10944
10945 ri = &(itemScriptData[itemid]);
10946 for ( int32_t q = 0; q < 1024; q++ )
10947 item_stack[itemid][q] = 0xFFFF;
10948 ri->Clear();
10949 item_doscript[itemid] = 1;
10950 itemscriptInitialised[itemid] = 0;
10951 ZScriptVersion::RunScript(SCRIPT_ITEM, itm.script, itemid);
10952 bind = game->get_bottle_slot(itm.misc1);
10953 }
10954 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
10955 if(bt)
10956 {
10957 word toFill[3] = { 0 };
10958 for(size_t q = 0; q < 3; ++q)
10959 {
10960 char c = bt->counter[q];
10961 if(c > -1)
10962 {
10963 if(bt->flags & (1<<q))
10964 {
10965 toFill[q] = (bt->amount[q]==100)
10966 ? game->get_maxcounter(c)
10967 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
10968 }
10969 else toFill[q] = bt->amount[q];
10970 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
10971 {
10972 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
10973 }
10974 }
10975 }
10976 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
10977 bool run = max > 0;
10978 if(get_bit(quest_rules, qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
10979 run = ((bt->counter[0] > -1 && !toFill[0]) || (bt->counter[1] > -1 && !toFill[1]) || (bt->counter[2] > -1 && !toFill[2]));
10980 else
10981 {
10982 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
10983 run = true;
10984 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
10985 run = true;
10986 }
10987 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
10988 {
10989 if(bt->flags & BTFLAG_CURESWJINX)
10990 {
10991 swordclk = 0;
10992 verifyAWpn();
10993 }
10994 if(bt->flags & BTFLAG_CUREITJINX)
10995 itemclk = 0;
10996 if(!paidmagic)
10997 paymagiccost(itemid);
10998 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
10999 sfx(itm.usesound,pan(x.getInt()));
11000 for(size_t q = 0; q < 20; ++q)
11001 do_refill_waitframe();
11002 double inc = max/60.0; //1 second
11003 double xtra[3]{ 0 };
11004 for(size_t q = 0; q < 60; ++q)
11005 {
11006 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
11007 sfx(QMisc.miscsfx[sfxREFILL]);
11008 for(size_t j = 0; j < 3; ++j)
11009 {
11010 xtra[j] += inc;
11011 word f = floor(xtra[j]);
11012 xtra[j] -= f;
11013 if(toFill[j] > f)
11014 {
11015 toFill[j] -= f;
11016 game->change_counter(f,bt->counter[j]);
11017 }
11018 else if(toFill[j])
11019 {
11020 game->change_counter(toFill[j],bt->counter[j]);
11021 toFill[j] = 0;
11022 }
11023 }
11024 do_refill_waitframe();
11025 }
11026 for(size_t j = 0; j < 3; ++j)
11027 {
11028 if(toFill[j])
11029 {
11030 game->change_counter(toFill[j],bt->counter[j]);
11031 toFill[j] = 0;
11032 }
11033 }
11034 for(size_t q = 0; q < 20; ++q)
11035 do_refill_waitframe();
11036 game->set_bottle_slot(itm.misc1, bt->next_type);
11037 }
11038 }
11039
11040 dowpn = -1;
11041 ret = false;
11042 break;
11043 }
11044
11045 case itype_note:
11046 {
11047 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11048 {
11049 return item_error();
11050 }
11051 if(!msg_active && itm.misc1 > 0 && itm.misc1 < MAXMSGS)
11052 {
11053 sfx(itm.usesound);
11054 donewmsg(itm.misc1);
11055 paymagiccost(itemid);
11056 }
11057 dowpn = -1;
11058 ret = false;
11059 break;
11060 }
11061
11062 case itype_mirror:
11063 doMirror(itemid);
11064 if(Quit)
11065 return false;
11066 ret = false;
11067 break;
11068
11069 case itype_rocs:
11070 {
11071
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 6 times.
67 if(!do_jump(itemid,false)) return false;
11072 61 ret = false;
11073 }
11074 61 break;
11075
11076 case itype_letter:
11077 {
11078
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
6 if(current_item(itype_letter)==i_letter &&
11079
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].room==rP_SHOP &&
11080
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 tmpscr[currscr<128?0:1].guy &&
11081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 ((currscr<128&&!(DMaps[currdmap].flags&dmfGUYCAVES))
11082
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 ||(currscr>=128&&DMaps[currdmap].flags&dmfGUYCAVES)) &&
11083 3 checkbunny(itemid)
11084 )
11085 {
11086 3 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11087
11088
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(usedid != -1)
11089 3 getitem(usedid, true, true);
11090
11091 3 sfx(tmpscr[currscr<128?0:1].secretsfx);
11092 3 setupscreen();
11093 3 action=none; FFCore.setHeroAction(none);
11094 3 }
11095
11096 3 ret = false;
11097 }
11098 3 break;
11099
11100 case itype_whistle:
11101 {
11102 bool whistleflag;
11103
11104
4/4
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 137 times.
141 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11105 {
11106 4 return item_error();
11107 }
11108
11109 137 paymagiccost(itemid);
11110 137 sfx(itm.usesound);
11111
11112
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 55 times.
137 if(dir==up || dir==right)
11113 82 ++blowcnt;
11114 else
11115 55 --blowcnt;
11116
11117 137 int sfx_count = 0;
11118
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 25157 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25159 times.
✓ Branch 6 taken 25020 times.
✓ Branch 7 taken 141 times.
25157 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < 180))
11119 {
11120 25020 sfx_count += 1;
11121 25020 advanceframe(true);
11122
11123
1/2
✓ Branch 0 taken 25020 times.
✗ Branch 1 not taken.
25020 if(Quit)
11124 return false;
11125 }
11126
11127
9/14
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 139 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 141 times.
✓ Branch 13 taken 2 times.
141 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11128
11129
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 15 times.
141 if((whistleflag=findentrance(x,y,mfWHISTLE,get_bit(quest_rules, qr_PERMANENT_WHISTLE_SECRETS))))
11130 15 didstuff |= did_whistle;
11131
11132
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 124 times.
141 if((didstuff&did_whistle && itm.flags&ITEM_FLAG1) || currscr>=128)
11133 17 return false;
11134
11135
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 122 times.
124 if(itm.flags&ITEM_FLAG1) didstuff |= did_whistle;
11136
11137
4/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 100 times.
124 if((tmpscr->flags&fWHISTLE) || (tmpscr->flags7 & fWHISTLEWATER)
11138
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 || (tmpscr->flags7&fWHISTLEPAL))
11139 {
11140 28 whistleclk=0; // signal to start drying lake or doing other stuff
11141 28 }
11142 else
11143 {
11144 100 int32_t where = itm.misc1;
11145
11146
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(where>right) where=dir^1;
11147
11148
5/6
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61 times.
161 if(((DMaps[currdmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[currdmap].flags&dmfWHIRLWINDRET) &&
11149
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
65 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
11150
4/12
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 61 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 61 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 61 times.
✗ Branch 11 not taken.
122 Lwpns.add(new weapon((zfix)(where==left?zfix(240):where==right?zfix(0):x),
11151
3/10
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 61 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 61 times.
✗ Branch 9 not taken.
61 (zfix)(where==down?zfix(0):where==up?zfix(160):y),
11152
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 (zfix)0,
11153 wWind,
11154 0, //type
11155 0,
11156 61 where,
11157
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
11158
11159 96 whistleitem=itemid;
11160 }
11161
11162 122 ret = false;
11163 }
11164 122 break;
11165
11166 case itype_bomb:
11167 {
11168 //Remote detonation
11169
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 576 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 580 times.
581 if(Lwpns.idCount(wLitBomb) >= zc_max(itm.misc2,1))
11170 {
11171 1 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11172
11173
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 while(Lwpns.idCount(wLitBomb) && ew->misc == 0)
11174 {
11175 //If this ever needs a version check, in the future. -z
11176 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 ) )
11177 {
11178 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
11179 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
11180 }
11181 ew->misc=50;
11182 ew->clk=ew->misc-3;
11183 ew->id=wBomb;
11184 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitBomb)));
11185 }
11186
11187 1 deselectbombs(false);
11188 1 return false;
11189 }
11190
11191
2/4
✓ Branch 0 taken 580 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 580 times.
580 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11192 {
11193 return item_error();
11194 }
11195
11196 580 paymagiccost(itemid);
11197
11198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 580 times.
580 if(itm.misc1>0) // If not remote bombs
11199 580 deselectbombs(false);
11200
11201
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 488 times.
580 if(isdungeon())
11202 {
11203
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 51 times.
488 wy=zc_max(wy,16);
11204 488 }
11205
11206
4/8
✓ Branch 0 taken 580 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 580 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 580 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 580 times.
✗ Branch 7 not taken.
1160 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitBomb,itm.fam_type,
11207
2/4
✓ Branch 0 taken 580 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 580 times.
✗ Branch 3 not taken.
580 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11208 580 sfx(WAV_PLACE,pan(wx));
11209 }
11210 580 break;
11211
11212 case itype_sbomb:
11213 {
11214 //Remote detonation
11215
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(Lwpns.idCount(wLitSBomb) >= zc_max(itm.misc2,1))
11216 {
11217 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11218
11219 while(Lwpns.idCount(wLitSBomb) && ew->misc == 0)
11220 {
11221 ew->misc=50;
11222 ew->clk=ew->misc-3;
11223 ew->id=wSBomb;
11224 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wLitSBomb)));
11225 }
11226
11227 deselectbombs(true);
11228 return false;
11229 }
11230
11231
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11232 {
11233 return item_error();
11234 }
11235
11236 14 paymagiccost(itemid);
11237
11238
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(itm.misc1>0) // If not remote bombs
11239 14 deselectbombs(true);
11240
11241
6/12
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14 times.
✗ Branch 11 not taken.
14 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wLitSBomb,itm.fam_type,itm.power*game->get_hero_dmgmult(),dir, itemid,getUID(),false,false,true));
11242 14 sfx(WAV_PLACE,pan(wx));
11243 }
11244 14 break;
11245
11246 case itype_wand:
11247 {
11248
2/2
✓ Branch 0 taken 363 times.
✓ Branch 1 taken 844 times.
1207 if(Lwpns.idCount(wMagic))
11249 {
11250 363 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11251 363 return false;
11252 }
11253
11254 844 int32_t bookid = current_item_id(itype_book);
11255
3/4
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 443 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 401 times.
844 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
11256
11257
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 844 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
844 if(!(itm.flags&ITEM_FLAG1) && !paybook) //Can the wand shoot without the book?
11258 {
11259 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11260 return false;
11261 }
11262
11263
4/6
✓ Branch 0 taken 844 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 844 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 843 times.
✓ Branch 5 taken 1 times.
844 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
11264 {
11265 1 return item_error();
11266 }
11267
11268
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 3 times.
843 if(Lwpns.idCount(wBeam))
11269 3 Lwpns.del(Lwpns.idFirst(wBeam));
11270
11271 int32_t type, pow;
11272
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 666 times.
843 if ( get_bit(quest_rules,qr_BROKENBOOKCOST) )
11273 {
11274
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 79 times.
177 type = bookid != -1 ? current_item(itype_book) : itm.fam_type;
11275
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 79 times.
177 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11276 177 }
11277 else
11278 {
11279
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.fam_type;
11280
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 363 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
666 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
11281 }
11282
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1686 times.
✓ Branch 4 taken 843 times.
✓ Branch 5 taken 843 times.
1686 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
11283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 843 times.
1686 if(dir!=(i^1))
11284 {
11285
5/10
✓ Branch 0 taken 843 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 843 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 843 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 843 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 843 times.
✗ Branch 9 not taken.
843 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
11286
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 401 times.
843 if(paybook)
11287 401 magic->linkedItem = bookid;
11288 //magic->dir = this->dir; //Save player dir for special weapons.
11289 843 Lwpns.add(magic);
11290 843 }
11291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 843 times.
843 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
11292 843 paymagiccost(itemid);
11293 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
11294
11295
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 401 times.
843 if(paybook)
11296 401 paymagiccost(current_item_id(itype_book));
11297
11298
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 442 times.
843 if(bookid != -1)
11299 {
11300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401 times.
401 if (( itemsbuf[bookid].flags & ITEM_FLAG4 ))
11301 {
11302 sfx(itemsbuf[bookid].misc2,pan(wx));
11303 }
11304 else
11305 {
11306 401 sfx(itm.usesound,pan(wx));
11307 }
11308 401 }
11309 else
11310 442 sfx(itm.usesound,pan(wx));
11311 }
11312 /*
11313 // Fireball Wand
11314 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
11315 switch (dir)
11316 {
11317 case up:
11318 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
11319 Lwpns.spr(Lwpns.Count()-1)->dir=up;
11320 break;
11321 case down:
11322 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
11323 Lwpns.spr(Lwpns.Count()-1)->dir=down;
11324 break;
11325 case left:
11326 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
11327 Lwpns.spr(Lwpns.Count()-1)->dir=left;
11328 break;
11329 case right:
11330 Lwpns.spr(Lwpns.Count()-1)->angle=0;
11331 Lwpns.spr(Lwpns.Count()-1)->dir=right;
11332 break;
11333 }
11334 Lwpns.spr(Lwpns.Count()-1)->clk=16;
11335 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
11336 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
11337 */
11338 843 break;
11339
11340 case itype_sword:
11341 {
11342
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12250 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
11343 {
11344 return item_error();
11345 }
11346
11347
4/4
✓ Branch 0 taken 2384 times.
✓ Branch 1 taken 9866 times.
✓ Branch 2 taken 2384 times.
✓ Branch 3 taken 9866 times.
12250 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
11348 {
11349 2384 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11350 2384 return false;
11351 }
11352
11353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9866 times.
9866 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
11354 9866 paymagiccost(itemid);
11355 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
11356 float temppower;
11357
11358
1/2
✓ Branch 0 taken 9866 times.
✗ Branch 1 not taken.
9866 if(itm.flags & ITEM_FLAG2)
11359 {
11360 9866 temppower=game->get_hero_dmgmult()*itm.power;
11361 9866 temppower=temppower*itm.misc2;
11362 9866 temppower=temppower/100;
11363 9866 }
11364 else
11365 {
11366 temppower = game->get_hero_dmgmult()*itm.misc2;
11367 }
11368
11369 //Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID()));
11370 //Add weapon script to sword beams.
11371
5/10
✓ Branch 0 taken 9866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9866 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9866 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9866 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9866 times.
✗ Branch 9 not taken.
9866 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.fam_type,int32_t(temppower),dir,itemid,getUID(),false,false,true));
11372 //weapon *w = (weapon*)Lwpns.spr(Lwpns.Count()-1); //the pointer to this beam
11373 //w->weaponscript = itm.weaponscript;
11374 //w->canrunscript = 0;
11375 9866 sfx(WAV_BEAM,pan(wx));
11376 }
11377 9866 break;
11378
11379 case itype_candle:
11380 {
11381 984 int32_t countid = itemid;
11382
2/2
✓ Branch 0 taken 956 times.
✓ Branch 1 taken 28 times.
984 if(get_bit(quest_rules, qr_CANDLES_SHARED_LIMIT))
11383 956 countid = -itype_candle;
11384
5/6
✓ Branch 0 taken 806 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 974 times.
984 if(itm.flags&ITEM_FLAG1 && usecounts[countid] >= zc_max(1, itm.misc3))
11385 {
11386 10 return false;
11387 }
11388
11389
3/4
✓ Branch 0 taken 974 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 911 times.
974 if(Lwpns.idCount(wFire) >= (itm.misc3 < 1 ? 2 : itm.misc3))
11390 {
11391 63 return false;
11392 }
11393
11394
3/4
✓ Branch 0 taken 911 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 903 times.
911 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11395 {
11396 8 return item_error();
11397 }
11398
11399 903 paymagiccost(itemid);
11400
11401
2/2
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 160 times.
903 if(itm.flags&ITEM_FLAG1) ++usecounts[countid];
11402
11403
4/8
✓ Branch 0 taken 903 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 903 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 903 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 903 times.
✗ Branch 7 not taken.
1806 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
11404 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11405 903 (itm.fam_type), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
11406
2/4
✓ Branch 0 taken 903 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 903 times.
✗ Branch 3 not taken.
903 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11407 903 sfx(itm.usesound,pan(wx));
11408 903 attack=wFire;
11409 }
11410 903 break;
11411
11412 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
11413 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
11414 {
11415 int32_t wtype = wScript1 + (itm.family-itype_script1);
11416 if(Lwpns.idCount(wtype))
11417 return false;
11418
11419 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11420 {
11421 return item_error();
11422 }
11423
11424 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11425 paymagiccost(itemid);
11426
11427 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11428 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11429 sfx(itm.usesound,pan(wx));
11430 }
11431 break;
11432
11433 case itype_icerod:
11434 {
11435 if(Lwpns.idCount(wIce))
11436 return false;
11437
11438 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11439 {
11440 return item_error();
11441 }
11442
11443 if(!get_bit(quest_rules, qr_CUSTOMWEAPON_IGNORE_COST))
11444 paymagiccost(itemid);
11445
11446 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11447 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = itm.misc1/100;
11448 sfx(itm.usesound,pan(wx));
11449 }
11450 break;
11451
11452 case itype_arrow:
11453 {
11454
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 495 times.
516 if(Lwpns.idCount(wArrow) > itm.misc2)
11455 21 return false;
11456
11457
2/4
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 495 times.
495 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11458 {
11459 return item_error();
11460 }
11461
11462 495 paymagiccost(itemid);
11463
11464
6/12
✓ Branch 0 taken 495 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 495 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 495 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 495 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 495 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 495 times.
✗ Branch 11 not taken.
495 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.fam_type,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
11465 495 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
11466 495 sfx(itm.usesound,pan(wx));
11467 }
11468 495 break;
11469
11470 case itype_bait:
11471 {
11472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
11473 return false;
11474
11475
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(!checkbunny(itemid))
11476 3 return item_error();
11477
11478
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 bool grumble = (tmpscr->room==rGRUMBLE && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)));
11479
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 bool checkcost = grumble || !(itm.flags & ITEM_FLAG4);
11480
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 bool paycost = grumble || !(itm.flags & (ITEM_FLAG4|ITEM_FLAG5));
11481
11482
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!grumble && (itm.flags & ITEM_FLAG2))
11483 return item_error(); //Only usable for grumble rooms
11484
11485
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(checkcost && !checkmagiccost(itemid))
11486 return item_error();
11487
11488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(paycost)
11489 6 paymagiccost(itemid);
11490 6 sfx(itm.usesound,pan(wx));
11491
11492
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(grumble)
11493 {
11494
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
11495 6 fadeclk=66;
11496 6 dismissmsg();
11497 6 clear_bitmap(pricesdisplaybuf);
11498 6 set_clip_state(pricesdisplaybuf, 1);
11499 // putscr(scrollbuf,0,0,tmpscr);
11500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
11501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!(itm.flags & ITEM_FLAG3)) //"Don't remove when feeding" flag
11502 {
11503 6 removeItemsOfFamily(game,itemsbuf,itype_bait);
11504 6 verifyBothWeapons();
11505 6 }
11506 6 sfx(tmpscr->secretsfx);
11507 6 return false;
11508 }
11509
11510 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
11511 break;
11512 }
11513
11514 case itype_brang:
11515 {
11516
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 7374 times.
7648 if(Lwpns.idCount(wBrang) > itm.misc2)
11517 274 return false;
11518
11519
2/4
✓ Branch 0 taken 7374 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7374 times.
7374 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11520 {
11521 return item_error();
11522 }
11523
11524 7374 paymagiccost(itemid);
11525 7374 current_item_power(itype_brang);
11526
6/12
✓ Branch 0 taken 7374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7374 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7374 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7374 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7374 times.
✗ Branch 11 not taken.
7374 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.fam_type,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
11527 }
11528 7374 break;
11529
11530 case itype_hookshot:
11531 case itype_switchhook:
11532 {
11533
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
76 if(inlikelike || Lwpns.idCount(wHookshot))
11534 return false;
11535
11536
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
76 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11537 {
11538 return item_error();
11539 }
11540 76 bool sw = itm.family == itype_switchhook;
11541
11542
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
76 if(sw && (itm.flags&ITEM_FLAG8))
11543 switchhook_cost_item = itemid;
11544 76 else paymagiccost(itemid);
11545
11546 76 bool use_hookshot=true;
11547 76 bool hit_hs = false, hit_solid = false, insta_switch = false;
11548
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 73 times.
76 int32_t max_layer = get_bit(quest_rules, qr_HOOKSHOTALLLAYER) ? 6 : (get_bit(quest_rules, qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11549 76 int32_t cpos = -1, ffcpos = -1;
11550
4/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 76 times.
170 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
11551 {
11552
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 22 times.
94 if(dir==up)
11553 {
11554
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(check_hshot(i,x+2,y-7,sw, &cpos, &ffcpos))
11555 hit_hs = true;
11556 22 }
11557
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 58 times.
72 else if(dir==down)
11558 {
11559
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(check_hshot(i,x+12,y+23,sw, &cpos, &ffcpos))
11560 hit_hs = true;
11561 14 }
11562
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 30 times.
58 else if(dir==left)
11563 {
11564
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(check_hshot(i,x-7,y+12,sw, &cpos, &ffcpos))
11565 hit_hs = true;
11566 28 }
11567
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 else if(dir==right)
11568 {
11569
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(check_hshot(i,x+23,y+12,sw, &cpos, &ffcpos))
11570 hit_hs = true;
11571 30 }
11572 //Diagonal Hookshot (6)
11573 else if(dir==r_down)
11574 {
11575 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11576 hit_hs = true;
11577 }
11578 else if(dir==l_down)
11579 {
11580 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11581 hit_hs = true;
11582 }
11583 else if(dir==r_up)
11584 {
11585 if(check_hshot(i,x+9,y+13,sw, &cpos, &ffcpos))
11586 hit_hs = true;
11587 }
11588 else if(dir==l_up)
11589 {
11590 if(check_hshot(i,x+6,y+13,sw, &cpos, &ffcpos))
11591 hit_hs = true;
11592 }
11593 94 }
11594
7/10
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 76 times.
✗ Branch 9 not taken.
76 if(dir==up && _walkflag(x+2,y+4,1,SWITCHBLOCK_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
11595 hit_solid = true;
11596
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(hit_hs)
11597 {
11598 if(sw)
11599 insta_switch = true; //switch immediately
11600 else use_hookshot = false; //No hooking against grabbable
11601 }
11602
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if(hit_solid && !insta_switch)
11603 use_hookshot = false;
11604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if(use_hookshot)
11605 {
11606 76 int32_t hookitem = itm.fam_type;
11607 76 int32_t hookpower = itm.power;
11608 76 byte allow_diagonal = (itm.flags & ITEM_FLAG2) ? 1 : 0;
11609
11610
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!Lwpns.has_space())
11611 {
11612 Lwpns.del(0);
11613 }
11614
11615
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!Lwpns.has_space(2))
11616 {
11617 Lwpns.del(0);
11618 }
11619
11620
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
76 switch(dir)
11621 {
11622 case up:
11623 {
11624 22 hookshot_used=true;
11625 22 hs_switcher = sw;
11626
4/8
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
44 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11627
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11628 22 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11629
5/10
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 22 times.
✗ Branch 9 not taken.
44 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
11630
2/4
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
22 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11631 22 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11632 22 hs_startx=wx;
11633 22 hs_starty=wy-4;
11634 }
11635 22 break;
11636
11637 case down:
11638 {
11639 14 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11640 14 hookshot_used=true;
11641 14 hs_switcher = sw;
11642
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
28 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11643
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11644 14 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11645
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
28 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11646
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11647 14 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11648 14 hs_startx=wx;
11649 14 hs_starty=wy;
11650 }
11651 14 break;
11652
11653 case left:
11654 {
11655 16 hookshot_used=true;
11656 16 hs_switcher = sw;
11657
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
32 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11658
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11659 16 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11660
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
32 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11661
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11662 16 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11663 16 hs_startx=wx-4;
11664 16 hs_starty=wy;
11665 }
11666 16 break;
11667
11668 case right:
11669 {
11670 24 hookshot_used=true;
11671 24 hs_switcher = sw;
11672
4/8
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✗ Branch 7 not taken.
48 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11673
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11674 24 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11675
4/8
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✗ Branch 7 not taken.
48 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11676
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11677 24 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11678 24 hs_startx=wx+4;
11679 24 hs_starty=wy;
11680 }
11681 24 break;
11682 //Diagonal Hookshot (7)
11683 case r_down:
11684 {
11685 hookshot_used=true;
11686 hs_switcher = sw;
11687 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11688 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11689 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11690 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11691 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11692 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11693 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11694 hs_startx=wx+4;
11695 hs_starty=wy;
11696 }
11697 break;
11698
11699 case r_up:
11700 {
11701 hookshot_used=true;
11702 hs_switcher = sw;
11703 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11704 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11705 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11706 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11707 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11708 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11709 hs_startx=wx+4;
11710 hs_starty=wy;
11711 }
11712 break;
11713
11714 case l_down:
11715 {
11716 hookshot_used=true;
11717 hs_switcher = sw;
11718 int32_t offset=get_bit(quest_rules,qr_HOOKSHOTDOWNBUG)?4:0;
11719 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
11720 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11721 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11722 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
11723 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11724 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11725 hs_startx=wx+4;
11726 hs_starty=wy;
11727 }
11728 break;
11729
11730 case l_up:
11731 {
11732 hookshot_used=true;
11733 hs_switcher = sw;
11734 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
11735 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11736 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11737 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
11738 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11739 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.family;
11740 hs_startx=wx+4;
11741 hs_starty=wy;
11742 }
11743 break;
11744 }
11745 76 hookshot_frozen=true;
11746 76 }
11747
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(insta_switch)
11748 {
11749 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
11750 if (cpos > -1) hooked_combopos = cpos;
11751 if (ffcpos > -1)
11752 {
11753 switching_object = &(tmpscr->ffcs[ffcpos]);
11754 switching_object->switch_hooked = true;
11755 }
11756 w->misc=2;
11757 w->step=0;
11758 doSwitchHook(itm.misc5);
11759 if(itm.usesound2)
11760 sfx(itm.usesound2,pan(int32_t(x)));
11761 else if(QMisc.miscsfx[sfxSWITCHED])
11762 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
11763 stop_sfx(itm.usesound);
11764 }
11765 }
11766 76 break;
11767
11768 case itype_dinsfire:
11769 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11770 return false;
11771
11772 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11773 {
11774 return item_error();
11775 }
11776
11777 paymagiccost(itemid);
11778 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11779 else {action=casting; FFCore.setHeroAction(casting);}
11780 magicitem=itemid;
11781 break;
11782
11783 case itype_faroreswind:
11784 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11785 return false;
11786
11787 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11788 {
11789 return item_error();
11790 }
11791
11792 paymagiccost(itemid);
11793 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11794 else {action=casting; FFCore.setHeroAction(casting);}
11795 magicitem=itemid;
11796 break;
11797
11798 case itype_nayruslove:
11799 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(x,y,old_x,old_y) || getOnSideviewLadder() || IsSideSwim())))
11800 return false;
11801
11802 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11803 {
11804 return item_error();
11805 }
11806
11807 paymagiccost(itemid);
11808 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
11809 else {action=casting; FFCore.setHeroAction(casting);}
11810 magicitem=itemid;
11811 break;
11812
11813 case itype_cbyrna:
11814 {
11815 //Beams already deployed
11816
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(Lwpns.idCount(wCByrna))
11817 {
11818 2 stopCaneOfByrna();
11819 2 return false;
11820 }
11821
11822
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11823 {
11824 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
11825 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
11826 return false;
11827 }
11828
11829 2 paymagiccost(itemid);
11830 2 last_cane_of_byrna_item_id = itemid;
11831 //zprint("itm.misc3: %d\n", itm.misc3);
11832
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for(int32_t i=0; i<itm.misc3; i++)
11833 {
11834 //byrna weapons are added here
11835 //space them apart
11836 //zprint("Added byrna weapon %d.\n", i);
11837 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
11838 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
11839
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11840 //Lwpns.add(new weapon((zfix)wx+cos(2 * PI / (i+1)),(zfix)wy+sin(2 * PI / (i+1)),(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
11841 //wx += cos(2 * PI / (itm.misc3-i));
11842 //wy += sin(2 * PI / (itm.misc3-i));
11843 2 }
11844
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(Lwpns.idCount(wCByrna)))
11845 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
11846 }
11847 2 break;
11848
11849 case itype_clock:
11850 {
11851 ret = false;
11852 if(!(itm.flags & ITEM_FLAG1))
11853 break; //Passive clock, don't use
11854 if((itm.flags & ITEM_FLAG2) && watch) //"Can't activate while clock active"
11855 break;
11856 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
11857 {
11858 return item_error();
11859 }
11860
11861 paymagiccost(itemid);
11862
11863 setClock(watch=true);
11864
11865 for(int32_t i=0; i<eMAXGUYS; i++)
11866 clock_zoras[i]=0;
11867
11868 clockclk=itm.misc1;
11869 sfx(itm.usesound);
11870 break;
11871 }
11872 case itype_killem:
11873 {
11874 ret = false;
11875 if(!(itm.flags & ITEM_FLAG1))
11876 break; //Passive killemall, don't use
11877
11878 if(!(checkbunny(itemid) && checkmagiccost(itemid))
11879 || !can_kill_em_all()) //No enemies onscreen
11880 {
11881 return item_error();
11882 }
11883
11884 paymagiccost(itemid);
11885
11886 kill_em_all();
11887 sfx(itm.usesound);
11888 break;
11889 }
11890 case itype_refill:
11891 {
11892 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11893 {
11894 return item_error();
11895 }
11896
11897 bool did_something = false;
11898
11899 if(itm.flags & ITEM_FLAG1) //Cure sword jinx
11900 {
11901 if(swordclk)
11902 did_something = true;
11903 swordclk = 0;
11904 verifyAWpn();
11905 }
11906 for(auto q = 0; q < 5; ++q)
11907 {
11908 auto ctr = itm.misc(q);
11909 if(unsigned(ctr) >= MAX_COUNTERS)
11910 continue;
11911 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
11912 if(!amnt) continue;
11913 bool gradual = itm.flags & ITEM_FLAG2;
11914 if(amnt > 0)
11915 {
11916 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
11917 {
11918 //Can't *do* anything... skip
11919 continue;
11920 }
11921 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
11922 {
11923 //Can't do anything unless affecting dcounter
11924 gradual = true;
11925 }
11926 }
11927 else //Negative
11928 {
11929 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
11930 {
11931 //Can't *do* anything... skip
11932 continue;
11933 }
11934 if(game->get_counter(ctr) <= 0)
11935 {
11936 //Can't do anything unless affecting dcounter
11937 gradual = true;
11938 }
11939 }
11940 did_something = true;
11941 if(gradual) //Gradual
11942 {
11943 game->change_dcounter(amnt, ctr);
11944 }
11945 else
11946 {
11947 game->change_counter(amnt, ctr);
11948 }
11949 }
11950 if(!did_something)
11951 {
11952 return item_error();
11953 }
11954 paymagiccost(itemid);
11955 sfx(itm.usesound);
11956 ret = false;
11957 break;
11958 }
11959
11960 default:
11961 1163 ret = false;
11962 1163 }
11963
11964
2/2
✓ Branch 0 taken 21502 times.
✓ Branch 1 taken 23 times.
21525 if(itm.flags & ITEM_DOWNGRADE)
11965 {
11966 23 game->set_item(itemid,false);
11967
11968 // Maybe Item Override has allowed the same item in both slots?
11969
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Bwpn == itemid)
11970 {
11971 Bwpn = 0;
11972 game->forced_bwpn = -1;
11973 verifyBWpn();
11974 }
11975
11976
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Awpn == itemid)
11977 {
11978 Awpn = 0;
11979 game->forced_awpn = -1;
11980 verifyAWpn();
11981 }
11982
11983
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Xwpn == itemid)
11984 {
11985 Xwpn = 0;
11986 game->forced_xwpn = -1;
11987 verifyXWpn();
11988 }
11989
11990
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(Ywpn == itemid)
11991 {
11992 Ywpn = 0;
11993 game->forced_ywpn = -1;
11994 verifyYWpn();
11995 }
11996 23 }
11997
11998 21525 return ret;
11999 24727 }
12000
12001
12002 734599 bool HeroClass::doattack()
12003 {
12004 //int32_t s = BSZ ? 0 : 11;
12005 734599 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
12006
12007
3/4
✓ Branch 0 taken 31486 times.
✓ Branch 1 taken 703113 times.
✓ Branch 2 taken 31486 times.
✗ Branch 3 not taken.
734599 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].family==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
12008
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 734599 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
734599 if(attack==wBugNet && bugnetid!=-1)
12009 {
12010 if(++attackclk >= NET_CLK_TOTAL)
12011 return false;
12012
12013 return true;
12014 }
12015
12016 // Abort attack if attackclk has run out and:
12017 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
12018 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
12019
12020
6/6
✓ Branch 0 taken 43309 times.
✓ Branch 1 taken 691290 times.
✓ Branch 2 taken 41694 times.
✓ Branch 3 taken 1615 times.
✓ Branch 4 taken 2287 times.
✓ Branch 5 taken 3191 times.
740077 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12021
12/12
✓ Branch 0 taken 34866 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 3586 times.
✓ Branch 3 taken 31280 times.
✓ Branch 4 taken 36903 times.
✓ Branch 5 taken 4791 times.
✓ Branch 6 taken 36216 times.
✓ Branch 7 taken 687 times.
✓ Branch 8 taken 3585 times.
✓ Branch 9 taken 1893 times.
✓ Branch 10 taken 2264 times.
✓ Branch 11 taken 1321 times.
41694 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12022 {
12023 39407 tapping=false;
12024 39407 return false;
12025 }
12026
12027
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 695088 times.
695192 if(attackclk>29)
12028 {
12029 104 tapping=false;
12030 104 return false;
12031 }
12032
12033
4/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 665589 times.
✓ Branch 2 taken 27699 times.
✓ Branch 3 taken 1800 times.
695088 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].family==itype_candle) ? directWpn : current_item_id(itype_candle);
12034
3/4
✓ Branch 0 taken 29499 times.
✓ Branch 1 taken 665589 times.
✓ Branch 2 taken 29499 times.
✗ Branch 3 not taken.
695088 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].family==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12035 // An attack can be "walked out-of" after 8 frames, unless it's:
12036 // * a sword stab
12037 // * a hammer pound
12038 // * a wand thrust
12039 // * a candle thrust
12040 // * a cane thrust
12041 // In which case it should continue.
12042
8/8
✓ Branch 0 taken 37288 times.
✓ Branch 1 taken 657800 times.
✓ Branch 2 taken 87422 times.
✓ Branch 3 taken 50134 times.
✓ Branch 4 taken 614283 times.
✓ Branch 5 taken 93651 times.
✓ Branch 6 taken 140217 times.
✓ Branch 7 taken 474066 times.
832399 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12043
5/6
✓ Branch 0 taken 137341 times.
✓ Branch 1 taken 2876 times.
✓ Branch 2 taken 11906 times.
✓ Branch 3 taken 125435 times.
✓ Branch 4 taken 11906 times.
✗ Branch 5 not taken.
140217 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12044
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 125405 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
137341 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12045
2/2
✓ Branch 0 taken 137311 times.
✓ Branch 1 taken 11906 times.
125435 && (attack != wBugNet) && attackclk>7))
12046 {
12047
8/8
✓ Branch 0 taken 47624 times.
✓ Branch 1 taken 2265 times.
✓ Branch 2 taken 45756 times.
✓ Branch 3 taken 1868 times.
✓ Branch 4 taken 43491 times.
✓ Branch 5 taken 2265 times.
✓ Branch 6 taken 2337 times.
✓ Branch 7 taken 41154 times.
224733 if(DrunkUp()||DrunkDown()||DrunkLeft()||DrunkRight())
12048 {
12049 8735 lstep = s;
12050 8735 return false;
12051 }
12052 41154 }
12053
12054
2/2
✓ Branch 0 taken 1916 times.
✓ Branch 1 taken 633673 times.
635589 if(charging==0)
12055 {
12056 633673 lstep=0;
12057 633673 }
12058
12059 // Work out the sword charge-up delay
12060 635589 int32_t magiccharge = 192, normalcharge = 64;
12061 635589 int32_t itemid = current_item_id(itype_chargering);
12062
12063
2/2
✓ Branch 0 taken 596522 times.
✓ Branch 1 taken 39067 times.
635589 if(itemid>=0)
12064 {
12065 39067 normalcharge = itemsbuf[itemid].misc1;
12066 39067 magiccharge = itemsbuf[itemid].misc2;
12067 39067 }
12068
12069 635589 int scrollid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12070 635589 int scroll2id = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12071
12072 635589 bool doCharge=true;
12073
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 635589 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
635589 if(z!=0 && fakez != 0)
12074 doCharge=false;
12075
2/2
✓ Branch 0 taken 474066 times.
✓ Branch 1 taken 161523 times.
635589 if(attack==wSword)
12076 {
12077
4/4
✓ Branch 0 taken 1661 times.
✓ Branch 1 taken 472405 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 1637 times.
474066 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12078 472429 doCharge=false;
12079
2/2
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 1220 times.
1637 else if(charging<=normalcharge)
12080 {
12081
3/6
✓ Branch 0 taken 1220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1220 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1220 times.
✗ Branch 5 not taken.
1220 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12082 doCharge=false;
12083 1220 }
12084 474066 }
12085
2/2
✓ Branch 0 taken 2876 times.
✓ Branch 1 taken 158647 times.
161523 else if(attack==wHammer)
12086 {
12087
4/4
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 2773 times.
✓ Branch 2 taken 95 times.
✓ Branch 3 taken 8 times.
2876 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
12088 2868 doCharge=false;
12089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if(charging<=normalcharge)
12090 {
12091
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
8 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12092 doCharge=false;
12093 8 }
12094 2876 }
12095 else
12096 158647 doCharge=false;
12097
12098 // charging up weapon...
12099
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 633944 times.
635589 if(doCharge)
12100 {
12101 // Increase charging while holding down button.
12102
3/4
✓ Branch 0 taken 1645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1517 times.
1645 if(spins==0 && charging<magiccharge)
12103 1517 charging++;
12104
12105 // Once a charging threshold is reached, play the sound.
12106
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1636 times.
1645 if(charging==normalcharge)
12107 {
12108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!(itemsbuf[scrollid].flags&ITEM_FLAG1))
12109 9 paymagiccost(scrollid);
12110 9 sfx(itemsbuf[scrollid].usesound2,pan(x.getInt()));
12111 9 }
12112
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 3 times.
1636 else if(charging==magiccharge)
12113 {
12114
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(scroll2id>-1 && checkbunny(scroll2id) && checkmagiccost(scroll2id))
12115 {
12116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(itemsbuf[scroll2id].flags&ITEM_FLAG1))
12117 3 paymagiccost(scroll2id);
12118 3 charging++; // charging>magiccharge signifies a successful supercharge.
12119 3 sfx(itemsbuf[scroll2id].usesound2,pan(x.getInt()));
12120 3 }
12121 3 }
12122 1645 }
12123
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 633914 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
633944 else if(attack==wCByrna && byrnaid!=-1)
12124 {
12125
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!(itemsbuf[byrnaid].wpn))
12126 {
12127 attack = wNone;
12128 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
12129 }
12130
12131 30 bool beamcount = false;
12132
12133
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 55 times.
81 for(int32_t i=0; i<Lwpns.Count(); i++)
12134 {
12135 55 weapon *w = ((weapon*)Lwpns.spr(i));
12136
12137
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 4 times.
55 if(w->id==wCByrna)
12138 {
12139 4 beamcount = true;
12140 4 break;
12141 }
12142 51 }
12143
12144 // If beams already deployed, remove them
12145
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
30 if(!attackclk && beamcount)
12146 {
12147 2 return startwpn(attackid); // Remove beams instantly
12148 }
12149
12150 // Otherwise, continue
12151 28 ++attackclk;
12152 28 }
12153 else
12154 {
12155 633914 ++attackclk;
12156
12157
6/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 633747 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 142 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 14 times.
633914 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
12158 {
12159 14 ++attackclk; // Won't continue charging
12160 14 charging=0;
12161 14 }
12162
12163 // Faster if spinning.
12164
2/2
✓ Branch 0 taken 633322 times.
✓ Branch 1 taken 592 times.
633914 if(spins>0)
12165 592 ++attackclk;
12166
12167 // Even faster if hurricane spinning.
12168
2/2
✓ Branch 0 taken 633482 times.
✓ Branch 1 taken 432 times.
633914 if(spins>5)
12169 432 attackclk+=2;
12170
12171 // If at a charging threshold, do a charged attack.
12172
5/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 633800 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 106 times.
✓ Branch 5 taken 8 times.
633914 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
12173 {
12174
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(attack==wSword)
12175 {
12176
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 bool super = charging>magiccharge && scroll2id > -1;
12177
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5 times.
8 int id = super ? scroll2id : scrollid;
12178 8 itemdata const& spinscroll = itemsbuf[id];
12179 8 bool paid = !(spinscroll.flags&ITEM_FLAG1);
12180
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8 if(!paid && checkbunny(id) && checkmagiccost(id))
12181 {
12182 paid = true;
12183 paymagiccost(id);
12184 }
12185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(paid)
12186 {
12187 8 currentscroll = id;
12188 8 spins=(spinscroll.misc1*4) + (super ? -3 : 1);
12189 8 attackclk=1;
12190 8 sfx(spinscroll.usesound,pan(x.getInt()));
12191
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(spinscroll.flags&ITEM_FLAG1)
12192 paymagiccost(id);
12193 8 }
12194 8 }
12195 else if(attack==wHammer && sideviewhammerpound())
12196 {
12197 bool super = charging>magiccharge && scroll2id > -1;
12198 int id = super ? scroll2id : scrollid;
12199 itemdata const& quakescroll = itemsbuf[id];
12200 bool paid = !(quakescroll.flags&ITEM_FLAG1);
12201 if(!paid && checkbunny(id) && checkmagiccost(id))
12202 {
12203 paid = true;
12204 paymagiccost(id);
12205 }
12206 if(paid)
12207 {
12208 currentscroll = id;
12209 spins = super ? 2 : 1;
12210 sfx(quakescroll.usesound,pan(x.getInt()));
12211 quakeclk=quakescroll.misc1;
12212
12213 // general area stun
12214 for(int32_t i=0; i<GuyCount(); i++)
12215 {
12216 if(!isflier(GuyID(i)))
12217 {
12218 StunGuy(i,quakescroll.misc2-distance(x,y,GuyX(i),GuyY(i)));
12219 }
12220 }
12221
12222 int hmrid = (directWpn>-1 && itemsbuf[directWpn].family==itype_hammer) ? directWpn : current_item_id(itype_hammer);
12223 int hmrlvl = hmrid < 0 ? 1 : itemsbuf[hmrid].fam_type;
12224 if(hmrlvl < 1) hmrlvl = 1;
12225 int rad = quakescroll.misc2;
12226 for(int pos = 0; pos < 176; ++pos)
12227 {
12228 if(distance(x,y,COMBOX(pos),COMBOY(pos)) > rad) continue;
12229 for(int lyr = 0; lyr < 7; ++lyr)
12230 {
12231 int cid = FFCore.tempScreens[lyr]->data[pos];
12232 newcombo const& cmb = combobuf[cid];
12233 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12234 {
12235 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12236 ? hmrlvl <= cmb.triggerlevel
12237 : hmrlvl >= cmb.triggerlevel)
12238 do_trigger_combo(lyr,pos);
12239 }
12240 }
12241 }
12242 word c = tmpscr->numFFC();
12243 for(int ff = 0; ff < c; ++ff)
12244 {
12245 ffcdata& ffc = tmpscr->ffcs[ff];
12246 newcombo const& cmb = combobuf[ffc.getData()];
12247 if(distance(x,y,ffc.x,ffc.y) > rad) continue;
12248 if(cmb.triggerflags[2] & ((super?combotriggerSQUAKESTUN:0)|combotriggerQUAKESTUN))
12249 {
12250 if((cmb.triggerflags[0]&combotriggerINVERTMINMAX)
12251 ? hmrlvl <= cmb.triggerlevel
12252 : hmrlvl >= cmb.triggerlevel)
12253 do_trigger_combo_ffc(ff);
12254 }
12255 }
12256 }
12257 }
12258 8 }
12259
6/6
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 633791 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 48 times.
633906 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
12260 48 charging++;
12261
12262
7/8
✓ Branch 0 taken 11690 times.
✓ Branch 1 taken 622224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 622224 times.
✓ Branch 4 taken 16908 times.
✓ Branch 5 taken 605316 times.
✓ Branch 6 taken 401422 times.
✓ Branch 7 taken 232492 times.
633914 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
12263 232492 charging=0;
12264
12265
2/2
✓ Branch 0 taken 632675 times.
✓ Branch 1 taken 1239 times.
633914 if(attackclk>=SWORDCHARGEFRAME)
12266 1239 tapping = false;
12267 }
12268
12269
6/8
✓ Branch 0 taken 50663 times.
✓ Branch 1 taken 584924 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 49669 times.
✓ Branch 4 taken 994 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 994 times.
635587 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
12270 {
12271 994 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
12272 }
12273
12274 634593 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
12275
12276
11/14
✓ Branch 0 taken 594699 times.
✓ Branch 1 taken 39894 times.
✓ Branch 2 taken 45863 times.
✓ Branch 3 taken 548836 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 45831 times.
✓ Branch 6 taken 32 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
634593 if(attackclk==13 || (attackclk==7 && spins>1 && attack != wHammer && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
12277 {
12278
12279
4/4
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 37903 times.
✓ Branch 2 taken 578 times.
✓ Branch 3 taken 1425 times.
39906 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].family==itype_sword) ? directWpn : current_item_id(itype_sword);
12280
2/2
✓ Branch 0 taken 39888 times.
✓ Branch 1 taken 18 times.
39906 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
12281
12282
4/4
✓ Branch 0 taken 39888 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 2673 times.
✓ Branch 3 taken 37215 times.
39906 if(wpnid>=0 && itemsbuf[wpnid].flags & ITEM_FLAG1)
12283 {
12284 37215 templife=templife*game->get_maxlife();
12285 37215 templife=templife/100;
12286 37215 }
12287 else
12288 {
12289 2691 templife*=game->get_hp_per_heart();
12290 }
12291
12292
2/2
✓ Branch 0 taken 17178 times.
✓ Branch 1 taken 22728 times.
39906 bool normalbeam = (int64_t(game->get_life())+(get_bit(quest_rules,qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
12293 39906 int32_t perilid = current_item_id(itype_perilscroll);
12294
3/4
✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 38269 times.
✓ Branch 2 taken 1637 times.
✗ Branch 3 not taken.
39909 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
12295
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1634 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
1637 && checkbunny(perilid) && checkmagiccost(perilid)
12296 // Must actually be able to shoot sword beams
12297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 && ((itemsbuf[wpnid].flags & ITEM_FLAG1)
12298
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
12299
12300
4/4
✓ Branch 0 taken 32735 times.
✓ Branch 1 taken 7171 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 32716 times.
39906 if(attack==wSword && !tapping)
12301 {
12302
4/4
✓ Branch 0 taken 32713 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 12267 times.
✓ Branch 3 taken 20446 times.
32716 if(perilbeam || normalbeam)
12303 {
12304
1/2
✓ Branch 0 taken 12270 times.
✗ Branch 1 not taken.
12270 if(attackclk==7)
12305 paymagiccost(crossid); // Pay the Cross Beams magic cost.
12306
12307
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12267 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
12270 if(perilbeam && !normalbeam)
12308 3 paymagiccost(perilid); // Pay the Peril Beam magic cost.
12309
12310 // TODO: Something that would be cheap but disgraceful to hack in at this point is
12311 // a way to make the peril/cross beam item's power stat influence the strength
12312 // of the peril/cross beam...
12313 12270 startwpn(attackid);
12314 12270 }
12315 20446 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12316 32716 }
12317
12318
2/2
✓ Branch 0 taken 38699 times.
✓ Branch 1 taken 1207 times.
39906 if(attack==wWand)
12319 1207 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
12320
12321
4/6
✓ Branch 0 taken 710 times.
✓ Branch 1 taken 39196 times.
✓ Branch 2 taken 710 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 710 times.
✗ Branch 5 not taken.
39906 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
12322 startwpn(attackid);
12323
12324
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 39904 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
39906 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
12325 2 startwpn(attackid);
12326 39906 }
12327
12328
2/2
✓ Branch 0 taken 595144 times.
✓ Branch 1 taken 39449 times.
634593 if(attackclk==14)
12329 39449 lstep = s;
12330
12331 634593 return true;
12332 683835 }
12333
12334 9864676 bool HeroClass::can_attack()
12335 {
12336
4/4
✓ Branch 0 taken 9698836 times.
✓ Branch 1 taken 165840 times.
✓ Branch 2 taken 5911276 times.
✓ Branch 3 taken 3787560 times.
9864676 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
12337
4/6
✓ Branch 0 taken 9864676 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9752092 times.
✓ Branch 3 taken 112584 times.
✓ Branch 4 taken 9752092 times.
✗ Branch 5 not taken.
10518878 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
12338
5/8
✓ Branch 0 taken 9752092 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9752092 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9752092 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9750396 times.
✓ Branch 7 taken 1696 times.
9752092 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
12339
3/4
✓ Branch 0 taken 9750396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8446052 times.
✓ Branch 3 taken 1304344 times.
9750396 || ((action==attacking||action==sideswimattacking)
12340
2/2
✓ Branch 0 taken 327108 times.
✓ Branch 1 taken 9423288 times.
9750396 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5))
12341
2/2
✓ Branch 0 taken 9750382 times.
✓ Branch 1 taken 327094 times.
9750396 && charging!=0))
12342 {
12343 768482 return false;
12344 }
12345
12346 9750382 int32_t r = (isdungeon()) ? 16 : 0;
12347 9750382 int32_t r2 = get_bit(quest_rules, qr_NOBORDER) ? 0 : 8;
12348
12349
4/5
✓ Branch 0 taken 3297320 times.
✓ Branch 1 taken 6453062 times.
✓ Branch 2 taken 2800708 times.
✓ Branch 3 taken 3652354 times.
✗ Branch 4 not taken.
9750382 if(!get_bit(quest_rules, qr_ITEMSONEDGES)) switch(dir)
12350 {
12351 case up:
12352 case down:
12353
2/2
✓ Branch 0 taken 2703078 times.
✓ Branch 1 taken 97630 times.
2800708 return !(y<(r2+r) || y>(160-r-r2));
12354
12355 case left:
12356 case right:
12357
2/2
✓ Branch 0 taken 3548174 times.
✓ Branch 1 taken 104180 times.
3652354 return !(x<(r2+r) || x>(240-r-r2));
12358 }
12359
12360 3297320 return true;
12361 10518864 }
12362
12363 8113 bool isRaftFlag(int32_t flag)
12364 {
12365
4/4
✓ Branch 0 taken 4055 times.
✓ Branch 1 taken 4058 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 3833 times.
8113 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
12366 }
12367
12368 3658113 void handle_lens_triggers(int32_t l_id)
12369 {
12370
2/2
✓ Branch 0 taken 3651854 times.
✓ Branch 1 taken 6259 times.
3658113 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & ITEM_FLAG6);
12371
2/2
✓ Branch 0 taken 3658113 times.
✓ Branch 1 taken 25606791 times.
29264904 for(auto layer = 0; layer < 7; ++layer)
12372 {
12373 25606791 mapscr* tmp = FFCore.tempScreens[layer];
12374
2/2
✓ Branch 0 taken 4506795216 times.
✓ Branch 1 taken 25606791 times.
4532402007 for(auto pos = 0; pos < 176; ++pos)
12375 {
12376 4506795216 newcombo const& cmb = combobuf[tmp->data[pos]];
12377
4/4
✓ Branch 0 taken 280896 times.
✓ Branch 1 taken 4506514320 times.
✓ Branch 2 taken 4506794838 times.
✓ Branch 3 taken 378 times.
4506795216 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12378 4506514320 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12379 {
12380 378 do_trigger_combo(layer, pos);
12381 378 }
12382 4506795216 }
12383 25606791 }
12384
2/2
✓ Branch 0 taken 3504506 times.
✓ Branch 1 taken 153607 times.
3658113 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
12385 {
12386 153607 word c = tmpscr->numFFC();
12387
2/2
✓ Branch 0 taken 153607 times.
✓ Branch 1 taken 820008 times.
973615 for(word i=0; i<c; i++)
12388 {
12389 820008 ffcdata& ffc = tmpscr->ffcs[i];
12390 820008 newcombo const& cmb = combobuf[ffc.getData()];
12391
3/4
✓ Branch 0 taken 1596 times.
✓ Branch 1 taken 818412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 820008 times.
820008 if(enabled ? (cmb.triggerflags[1] & combotriggerLENSON)
12392 818412 : (cmb.triggerflags[1] & combotriggerLENSOFF))
12393 {
12394 do_trigger_combo_ffc(i);
12395 break;
12396 }
12397 820008 }
12398 153607 }
12399 3658113 }
12400
12401 4997586 void do_lens()
12402 {
12403
2/2
✓ Branch 0 taken 1339473 times.
✓ Branch 1 taken 3658113 times.
4997586 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
12404 {
12405 1339473 do_210_lens();
12406 1339473 return;
12407 }
12408
12409 3658113 int32_t wpnPressed = getWpnPressed(itype_lens);
12410
6/6
✓ Branch 0 taken 6256 times.
✓ Branch 1 taken 3651857 times.
✓ Branch 2 taken 375 times.
✓ Branch 3 taken 3651482 times.
✓ Branch 4 taken 390370 times.
✓ Branch 5 taken 3261112 times.
3658113 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
12411
2/2
✓ Branch 0 taken 2727571 times.
✓ Branch 1 taken 930542 times.
3658113 if(itemid >= 0)
12412 {
12413
8/10
✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 925199 times.
✓ Branch 2 taken 5343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 693 times.
✓ Branch 5 taken 4650 times.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 527 times.
930542 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
12414 {
12415
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 209 times.
527 if(lensid<0)
12416 {
12417 209 lensid=itemid;
12418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(itemsbuf[itemid].family == itype_lens)
12419 209 Hero.setLastLensID(itemid);
12420
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 12 times.
209 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12421 209 }
12422
12423 527 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
12424
12425
2/10
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 527 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
527 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12426 {
12427 //clear the item script stack for a new script
12428 //itemScriptData[(itemid & 0xFFF)].Clear();
12429 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12430 ri = &(itemScriptData[itemid]);
12431 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12432 ri->Clear();
12433 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12434 item_doscript[itemid] = 1;
12435 itemscriptInitialised[itemid] = 0;
12436 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12437 did_scriptl=true;
12438 }
12439
12440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12441 527 else lensclk = 12;
12442 527 }
12443 else
12444 {
12445 930015 did_scriptl=false;
12446
2/2
✓ Branch 0 taken 5732 times.
✓ Branch 1 taken 924283 times.
930015 if(!lensclk)
12447 {
12448
12449
2/2
✓ Branch 0 taken 924077 times.
✓ Branch 1 taken 206 times.
924283 if(lensid>-1)
12450 {
12451 206 lensid=-1;
12452 206 lensclk = 0;
12453
12454
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 11 times.
206 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12455 206 }
12456 924283 }
12457 }
12458 930542 }
12459 3658113 handle_lens_triggers(lensid);
12460 4997586 }
12461 //Add 2.10 version check to call this
12462 1339473 void do_210_lens()
12463 {
12464
3/4
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 1337793 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1337793 times.
1339473 int32_t itemid = lensid >= 0 ? lensid : directWpn>-1 ? directWpn : current_item_id(itype_lens);
12465
12466
2/2
✓ Branch 0 taken 367843 times.
✓ Branch 1 taken 971630 times.
1339473 if(itemid<0)
12467 971630 return;
12468
12469
6/8
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 366163 times.
✓ Branch 2 taken 1680 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✓ Branch 5 taken 1432 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 248 times.
367843 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
12470 {
12471
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 234 times.
248 if(lensid<0)
12472 {
12473 234 lensid=itemid;
12474
12475
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
12476 234 }
12477
12478 248 paymagiccost(itemid, true);
12479
12480
2/10
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
248 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(item_doscript[itemid] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
12481 {
12482 //clear the item script stack for a new script
12483 //itemScriptData[(itemid & 0xFFF)].Clear();
12484 ri = &(itemScriptData[itemid]);
12485 for ( int32_t q = 0; q < 1024; q++ ) item_stack[itemid][q] = 0xFFFF;
12486 ri->Clear();
12487 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(itemid & 0xFFF)][q] = 0;
12488 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid & 0xFFF);
12489 item_doscript[itemid] = 1;
12490 itemscriptInitialised[itemid] = 0;
12491 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[itemid].script, itemid);
12492 did_scriptl=true;
12493 }
12494
12495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
12496 248 else lensclk = 12;
12497 248 }
12498 else
12499 {
12500 367595 did_scriptl=false;
12501
12502
6/8
✓ Branch 0 taken 1666 times.
✓ Branch 1 taken 365929 times.
✓ Branch 2 taken 1432 times.
✓ Branch 3 taken 234 times.
✓ Branch 4 taken 1432 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1432 times.
✗ Branch 7 not taken.
367595 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
12503 {
12504 234 lensid=-1;
12505 234 lensclk = 0;
12506
12507
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(get_bit(quest_rules,qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
12508 234 }
12509 }
12510 1339473 }
12511
12512 4716 void HeroClass::do_hopping()
12513 {
12514 4716 do_lens();
12515
12516
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 4567 times.
4716 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
12517 //Possible fix for exiting water in diagonal movement. -Z
12518 {
12519 149 int32_t flippers_id = current_item_id(itype_flippers);
12520
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 146 times.
149 if(diveclk>0)
12521 {
12522 3 --diveclk;
12523
2/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && DrunkrAbtn()) //Cancellable Diving -V
12524 {
12525 diveclk = itemsbuf[flippers_id].misc2;
12526 }
12527 3 }
12528
1/2
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
146 else if(DrunkrAbtn())
12529 {
12530 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
12531 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
12532
12533 if(global_diving==screen_diving)
12534 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
12535 }
12536
12537
3/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 149 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
149 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
12538 {
12539 149 SetSwim();
12540 149 hopclk = 0;
12541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (!IsSideSwim())
12542 {
12543 149 charging = attackclk = 0;
12544 149 tapping = false;
12545 149 }
12546 149 }
12547 else
12548 {
12549 herostep();
12550
12551 if(!isDiving() || (frame&1))
12552 {
12553 switch(dir)
12554 {
12555 case up:
12556 y -= 1;
12557 break;
12558
12559 case down:
12560 y += 1;
12561 break;
12562
12563 case left:
12564 x -= 1;
12565 break;
12566
12567 case right:
12568 x += 1;
12569 break;
12570 }
12571 }
12572 }
12573 149 }
12574 else // hopping in or out (need to separate the cases...)
12575 {
12576
2/4
✓ Branch 0 taken 4567 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4567 times.
4567 if((diagonalMovement||NO_GRIDLOCK))
12577 {
12578 if(hopclk==1) //hopping out
12579 //>= 1 possible fix for getting stuck on land edges.
12580 //No, this is not a clock. it's a type. 1 == out, 2 == in.
12581 {
12582 if(hopdir!=-1) dir=hopdir;
12583
12584 landswim=0;
12585
12586 if(dir==up)
12587 {
12588 herostep();
12589 herostep();
12590 int32_t sidestep=0;
12591
12592 if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12593 sidestep=1;
12594 else if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12595 sidestep=2;
12596
12597 if(sidestep==1) x++;
12598 else if(sidestep==2) x--;
12599 else y--;
12600
12601 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12602 {
12603 hopclk=0;
12604 diveclk=0;
12605 action=none; FFCore.setHeroAction(none);
12606 hopdir=-1;
12607 }
12608 }
12609
12610 if(dir==down)
12611 {
12612 herostep();
12613 herostep();
12614 int32_t sidestep=0;
12615
12616 if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12617 sidestep=1;
12618 else if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12619 sidestep=2;
12620
12621 if(sidestep==1) x++;
12622 else if(sidestep==2) x--;
12623 else y++;
12624
12625 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12626 {
12627 hopclk=0;
12628 diveclk=0;
12629 action=none; FFCore.setHeroAction(none);
12630 hopdir=-1;
12631 }
12632 }
12633
12634 if(dir==left)
12635 {
12636 herostep();
12637 herostep();
12638 int32_t sidestep=0;
12639
12640 if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12641 sidestep=1;
12642 else if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12643 sidestep=2;
12644
12645 if(sidestep==1) y++;
12646 else if(sidestep==2) y--;
12647 else x--;
12648
12649 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12650 {
12651 hopclk=0;
12652 diveclk=0;
12653 action=none; FFCore.setHeroAction(none);
12654 hopdir=-1;
12655 }
12656 }
12657
12658 if(dir==right)
12659 {
12660 herostep();
12661 herostep();
12662 int32_t sidestep=0;
12663
12664 if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12665 sidestep=1;
12666 else if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12667 sidestep=2;
12668
12669 if(sidestep==1) y++;
12670 else if(sidestep==2) y--;
12671 else x++;
12672
12673 if(!iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12674 {
12675 hopclk=0;
12676 diveclk=0;
12677 action=none; FFCore.setHeroAction(none);
12678 hopdir=-1;
12679 }
12680 }
12681 }
12682
12683 if(hopclk==2) //hopping in
12684 {
12685 landswim=0;
12686
12687 if(dir==up)
12688 {
12689 herostep();
12690 herostep();
12691 int32_t sidestep=0;
12692
12693 if(!iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12694 sidestep=1;
12695 else if(iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+15,y+(bigHitbox?0:8)-1, true, false))
12696 sidestep=2;
12697
12698 if(sidestep==1) x++;
12699 else if(sidestep==2) x--;
12700 else y--;
12701
12702 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12703 {
12704 hopclk=0xFF;
12705 diveclk=0;
12706 SetSwim();
12707 }
12708 }
12709
12710 if(dir==down)
12711 {
12712 herostep();
12713 herostep();
12714 int32_t sidestep=0;
12715
12716 if(!iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12717 sidestep=1;
12718 else if(iswaterex(MAPCOMBO(x,y+16), currmap, currscr, -1, x,y+16, true, false) && iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16, true, false) && !iswaterex(MAPCOMBO(x+15,y+16), currmap, currscr, -1, x+15,y+16, true, false))
12719 sidestep=2;
12720
12721 if(sidestep==1) x++;
12722 else if(sidestep==2) x--;
12723 else y++;
12724
12725 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt(),y.getInt()+15), currmap, currscr, -1, x.getInt(),y.getInt()+15, true, false))
12726 {
12727 hopclk=0xFF;
12728 diveclk=0;
12729 SetSwim();
12730 if (!IsSideSwim()) reset_swordcharge();
12731 }
12732 }
12733
12734 if(dir==left)
12735 {
12736 herostep();
12737 herostep();
12738 int32_t sidestep=0;
12739
12740 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?8:12)), currmap, currscr, -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12741 sidestep=1;
12742 else if(iswaterex(MAPCOMBO(x-1,y+(bigHitbox?0:8)), currmap, currscr, -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x-1,y+(bigHitbox?7:11)), currmap, currscr, -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x-1,y+15), currmap, currscr, -1, x-1,y+15, true, false))
12743 sidestep=2;
12744
12745 if(sidestep==1) y++;
12746 else if(sidestep==2) y--;
12747 else x--;
12748
12749 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12750 {
12751 hopclk=0xFF;
12752 diveclk=0;
12753 SetSwim();
12754 }
12755 }
12756
12757 if(dir==right)
12758 {
12759 herostep();
12760 herostep();
12761
12762 int32_t sidestep=0;
12763
12764 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?8:12)), currmap, currscr, -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12765 sidestep=1;
12766 else if(iswaterex(MAPCOMBO(x+16,y+(bigHitbox?0:8)), currmap, currscr, -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex(MAPCOMBO(x+16,y+(bigHitbox?7:11)), currmap, currscr, -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex(MAPCOMBO(x+16,y+15), currmap, currscr, -1, x+16,y+15, true, false))
12767 sidestep=2;
12768
12769 if(sidestep==1) y++;
12770 else if(sidestep==2) y--;
12771 else x++;
12772
12773 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), currmap, currscr, -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex(MAPCOMBO(x.getInt()+15,y.getInt()+8), currmap, currscr, -1, x.getInt()+15,y.getInt()+8, true, false))
12774 {
12775 hopclk=0xFF;
12776 diveclk=0;
12777 SetSwim();
12778 }
12779 }
12780 }
12781
12782 }
12783 else
12784 {
12785
7/8
✓ Branch 0 taken 1744 times.
✓ Branch 1 taken 2823 times.
✓ Branch 2 taken 1744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1298 times.
✓ Branch 5 taken 446 times.
✓ Branch 6 taken 240 times.
✓ Branch 7 taken 2583 times.
4567 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
12786 {
12787 446 action=none; FFCore.setHeroAction(none);
12788 446 hopclk = 0;
12789 446 diveclk = 0;
12790
12791
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 229 times.
446 if(iswaterex(MAPCOMBO(x.getInt(),y.getInt()+8), currmap, currscr, -1, x.getInt(),y.getInt()+8, true, false))
12792 {
12793 // hopped in
12794 229 SetSwim();
12795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229 times.
229 if (!IsSideSwim()) attackclk = charging = spins = 0;
12796 229 }
12797 446 }
12798 else
12799 {
12800 4121 herostep();
12801 4121 herostep();
12802
12803
2/2
✓ Branch 0 taken 3877 times.
✓ Branch 1 taken 244 times.
4121 if(++hero_count>(16*hero_animation_speed))
12804 244 hero_count=0;
12805
12806 4121 int32_t xofs2 = x.getInt()&15;
12807 4121 int32_t yofs2 = y.getInt()&15;
12808 4121 int32_t s = 1 + (frame&1);
12809
12810
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 568 times.
✓ Branch 2 taken 970 times.
✓ Branch 3 taken 1204 times.
✓ Branch 4 taken 1379 times.
4121 switch(dir)
12811 {
12812 case up:
12813
3/4
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 402 times.
✗ Branch 3 not taken.
568 if(yofs2<3 || yofs2>13) --y;
12814 402 else y-=s;
12815
12816 568 break;
12817
12818 case down:
12819
4/4
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 680 times.
970 if(yofs2<3 || yofs2>13) ++y;
12820 680 else y+=s;
12821
12822 970 break;
12823
12824 case left:
12825
4/4
✓ Branch 0 taken 1052 times.
✓ Branch 1 taken 152 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 856 times.
1204 if(xofs2<3 || xofs2>13) --x;
12826 856 else x-=s;
12827
12828 1204 break;
12829
12830 case right:
12831
4/4
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 185 times.
✓ Branch 3 taken 967 times.
1379 if(xofs2<3 || xofs2>13) ++x;
12832 967 else x+=s;
12833
12834 1379 break;
12835 }
12836 }
12837 }
12838 }
12839 4716 }
12840
12841 60532 void HeroClass::do_rafting()
12842 {
12843
12844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60532 times.
60532 if(toogam)
12845 {
12846 action=none; FFCore.setHeroAction(none);
12847 return;
12848 }
12849
12850 60532 FFCore.setHeroAction(rafting);
12851
12852 60532 do_lens();
12853
12854 60532 herostep();
12855
12856 //Calculate rafting speed
12857 60532 int32_t raft_item = current_item_id(itype_raft);
12858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60532 times.
60532 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
12859 60532 raft_step = vbound(raft_step, -8, 5);
12860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60532 times.
60532 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
12861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60532 times.
60532 if(raft_step < 0) raft_step = 1;
12862 60532 int32_t step_inc = 1 << (raft_step - 1);
12863 // Fix position
12864
1/2
✓ Branch 0 taken 60532 times.
✗ Branch 1 not taken.
60532 if(raft_step > 1)
12865 {
12866 if(x.getInt() & (step_inc-1))
12867 {
12868 x = x.getInt() & ~(step_inc-1);
12869 }
12870 if(y.getInt() & (step_inc-1))
12871 {
12872 y = y.getInt() & ~(step_inc-1);
12873 }
12874 }
12875 // Inc clock, check if we need to move this frame
12876 60532 ++raftclk;
12877
2/4
✓ Branch 0 taken 60532 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60532 times.
60532 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
12878
12879
4/4
✓ Branch 0 taken 28792 times.
✓ Branch 1 taken 31740 times.
✓ Branch 2 taken 24679 times.
✓ Branch 3 taken 4113 times.
64532 if(!(x.getInt()&15) && !(y.getInt()&15))
12880 {
12881 // this sections handles switching to raft branches
12882
3/4
✓ Branch 0 taken 3892 times.
✓ Branch 1 taken 221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3892 times.
4113 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
12883 {
12884
7/8
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 120 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
221 if(dir!=down && DrunkUp() && (isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12885 {
12886 34 dir = up;
12887 34 goto skip;
12888 }
12889
12890
7/8
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 49 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 34 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
187 if(dir!=up && DrunkDown() && (isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12891 {
12892 34 dir = down;
12893 34 goto skip;
12894 }
12895
12896
7/8
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 94 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 19 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
153 if(dir!=right && DrunkLeft() && (isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12897 {
12898 19 dir = left;
12899 19 goto skip;
12900 }
12901
12902
7/8
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
134 if(dir!=left && DrunkRight() && (isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12903 {
12904 26 dir = right;
12905 26 goto skip;
12906 }
12907 108 }
12908
2/4
✓ Branch 0 taken 3892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3892 times.
3892 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
12909 {
12910 if(dir == left) dir = right;
12911 else if(dir == right) dir = left;
12912 else if(dir == up) dir = down;
12913 else if(dir == down) dir = up;
12914 }
12915
12916
12917
3/4
✓ Branch 0 taken 766 times.
✓ Branch 1 taken 3234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 766 times.
4000 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
12918 {
12919
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 362 times.
766 if(dir<left) //going up or down
12920 {
12921
3/4
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 244 times.
404 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
12922 160 dir=right;
12923
3/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
244 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
12924 140 dir=left;
12925
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 7 times.
104 else if(y>0 && y<160)
12926 {
12927 90 action=none; FFCore.setHeroAction(none);
12928 90 x = x.getInt();
12929 90 y = y.getInt();
12930 90 }
12931 404 }
12932 else //going left or right
12933 {
12934
3/4
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 212 times.
362 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
12935 150 dir=down;
12936
3/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 141 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71 times.
212 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
12937 141 dir=up;
12938
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71 times.
71 else if(x>0 && x<240)
12939 {
12940 71 action=none; FFCore.setHeroAction(none);
12941 71 x = x.getInt();
12942 71 y = y.getInt();
12943 71 }
12944 }
12945 766 }
12946 4000 }
12947
12948 skip:
12949
12950
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13421 times.
✓ Branch 2 taken 13085 times.
✓ Branch 3 taken 15689 times.
✓ Branch 4 taken 18337 times.
60532 switch(dir)
12951 {
12952 case up:
12953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13421 times.
13421 if(x.getInt()&15)
12954 {
12955 if(x.getInt()&8)
12956 x++;
12957 else x--;
12958 }
12959 13421 else y -= step_inc;
12960
12961 13421 break;
12962
12963 case down:
12964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13085 times.
13085 if(x.getInt()&15)
12965 {
12966 if(x.getInt()&8)
12967 x++;
12968 else x--;
12969 }
12970 13085 else y += step_inc;
12971
12972 13085 break;
12973
12974 case left:
12975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15689 times.
15689 if(y.getInt()&15)
12976 {
12977 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12978 {
12979 if ((y.getInt() % 16) < 4) y--;
12980 else y++;
12981 }
12982 else
12983 {
12984 if(y.getInt()&8)
12985 y++;
12986 else y--;
12987 }
12988 }
12989 15689 else x -= step_inc;
12990
12991 15689 break;
12992
12993 case right:
12994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18337 times.
18337 if(y.getInt()&15)
12995 {
12996 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
12997 {
12998 if ((y.getInt() % 16) <= 4) y--;
12999 else y++;
13000 }
13001 else
13002 {
13003 if(y.getInt()&8)
13004 y++;
13005 else y--;
13006 }
13007 }
13008 18337 else x += step_inc;
13009
13010 18337 break;
13011 }
13012 60532 }
13013
13014 9 bool HeroClass::try_hover()
13015 {
13016
6/10
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
9 if(hoverclk <= 0 && can_use_item(itype_hoverboots,i_hoverboots) && !ladderx && !laddery && !(hoverflags & HOV_OUT))
13017 {
13018 2 int32_t itemid = current_item_id(itype_hoverboots);
13019
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hoverclk < 0)
13020 hoverclk = -hoverclk;
13021 else
13022 {
13023 2 fall = fakefall = jumping = 0;
13024
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].misc1)
13025 2 hoverclk = itemsbuf[itemid].misc1;
13026 else
13027 {
13028 hoverclk = 1;
13029 hoverflags |= HOV_INF;
13030 }
13031
13032
13033 2 sfx(itemsbuf[itemid].usesound,pan(x.getInt()));
13034 }
13035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].wpn)
13036
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 decorations.add(new dHover(x, y, dHOVER, 0));
13037 2 return true;
13038 }
13039 7 return false;
13040 9 }
13041
13042 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
13043 //Returns '-1' if not being pulled
13044 //Returns '-2' if should be falling in
13045 19200534 int32_t HeroClass::check_pitslide(bool ignore_hover)
13046 {
13047 //Pitfall todo -Emily
13048 //Iron boots; can't fight slipping, 2px/frame
13049 //Scripted variables to read pull dir/clk (clk only for non-hero)
13050 //Implement falling for all sprite types (npc AI)
13051 // Fall/slipping tiles for enemies
13052 // Fall/slipping SFX for enemies
13053 // Fall SFX for items/weapons
13054 // Weapons/Misc sprite shared for falling items/weapons
13055 //Maybe slip SFX for Hero?
13056 // Weapons/Misc sprite override for falling sprite?
13057 //Update std.zh with relevant new stuff
13058
2/2
✓ Branch 0 taken 988271 times.
✓ Branch 1 taken 18212263 times.
19200534 if(can_pitfall(ignore_hover))
13059 {
13060
2/2
✓ Branch 0 taken 1600076 times.
✓ Branch 1 taken 16612187 times.
18212263 bool can_diag = (diagonalMovement || get_bit(quest_rules,qr_DISABLE_4WAY_GRIDLOCK));
13061 18212263 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
13062 18212263 int32_t ispitbl = getpitfall(x,y+15);
13063 18212263 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
13064 18212263 int32_t ispitbr = getpitfall(x+15,y+15);
13065 18212263 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
13066 18212263 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
13067 18212263 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
13068 18212263 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
13069 18212263 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
13070 18212263 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13071 18212263 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13072 18212263 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13073 static const int32_t flag_pit_irresistable = (1<<24);
13074
5/5
✓ Branch 0 taken 18206007 times.
✓ Branch 1 taken 472 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 2969 times.
✓ Branch 4 taken 2706 times.
18212263 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13075 {
13076 472 case 4: return -2; //Fully over pit; fall in
13077 case 3:
13078 {
13079
5/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
109 if(ispitul && ispitur && ispitbl) //UL_3
13080 {
13081
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(ispitul_50)
13082 {
13083
3/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13084 6 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13085 }
13086 }
13087
3/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
87 else if(ispitul && ispitur && ispitbr) //UR_3
13088 {
13089 if(ispitur_50)
13090 {
13091 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13092 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13093 }
13094 }
13095
4/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 83 times.
87 else if(ispitul && ispitbl && ispitbr) //BL_3
13096 {
13097
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 74 times.
83 if(ispitbl_50)
13098 {
13099
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
9 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13100 9 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13101 }
13102 74 }
13103
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 else if(ispitbl && ispitur && ispitbr) //BR_3
13104 {
13105
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(ispitbr_50)
13106 {
13107
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13108 4 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13109 }
13110 }
13111 74 break;
13112 }
13113 case 2:
13114 {
13115
4/4
✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 1663 times.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 3 times.
2969 if(ispitul && ispitur) //Up
13116 {
13117
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(DrunkDown())
13118 {
13119
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(ispitul_75 && ispitur_75) //Straight up
13120 {
13121 return up | flag_pit_irresistable | (ispitul << 8);
13122 }
13123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(ispitul_75)
13124 {
13125 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
13126 }
13127
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if(ispitur_75)
13128 {
13129 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
13130 }
13131 3 else return -1;
13132 }
13133 else
13134 {
13135 if(ispitul_50 && ispitur_50) //Straight up
13136 {
13137 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13138 }
13139 else if(ispitul_50)
13140 {
13141 if(DrunkRight() && !ispitul_75) return -1;
13142 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13143 }
13144 else if(ispitur_50)
13145 {
13146 if(DrunkLeft() && !ispitur_75) return -1;
13147 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13148 }
13149 }
13150 }
13151
4/4
✓ Branch 0 taken 1605 times.
✓ Branch 1 taken 1361 times.
✓ Branch 2 taken 1303 times.
✓ Branch 3 taken 302 times.
2966 else if(ispitbl && ispitbr) //Down
13152 {
13153
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 290 times.
302 if(DrunkUp())
13154 {
13155
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(ispitbl_75 && ispitbr_75) //Straight down
13156 {
13157 return down | flag_pit_irresistable | (ispitbl << 8);
13158 }
13159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbl_75)
13160 {
13161 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
13162 }
13163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 else if(ispitbr_75)
13164 {
13165 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
13166 }
13167 12 else return -1;
13168 }
13169 else
13170 {
13171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
290 if(ispitbl_50 && ispitbr_50) //Straight down
13172 {
13173 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
13174 }
13175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbl_50)
13176 {
13177 if(DrunkRight() && !ispitbl_75) return -1;
13178 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13179 }
13180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 290 times.
290 else if(ispitbr_50)
13181 {
13182 if(DrunkLeft() && !ispitbr_75) return -1;
13183 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13184 }
13185 }
13186 290 }
13187
3/4
✓ Branch 0 taken 1303 times.
✓ Branch 1 taken 1361 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1303 times.
2664 else if(ispitbl && ispitul) //Left
13188 {
13189
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1161 times.
1303 if(DrunkRight())
13190 {
13191
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
142 if(ispitul_75 && ispitbl_75) //Straight left
13192 {
13193 return left | flag_pit_irresistable | (ispitul << 8);
13194 }
13195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(ispitul_75)
13196 {
13197 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
13198 }
13199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(ispitbl_75)
13200 {
13201 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
13202 }
13203 142 else return -1;
13204 }
13205 else
13206 {
13207
3/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
1161 if(ispitul_50 && ispitbl_50) //Straight left
13208 {
13209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
13210 }
13211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 else if(ispitul_50)
13212 {
13213 if(DrunkDown() && !ispitul_75) return -1;
13214 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13215 }
13216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1140 times.
1140 else if(ispitbl_50)
13217 {
13218 if(DrunkUp() && !ispitbl_75) return -1;
13219 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13220 }
13221 }
13222 1140 }
13223
2/4
✓ Branch 0 taken 1361 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1361 times.
1361 else if(ispitbr && ispitur) //Right
13224 {
13225
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1232 times.
1361 if(DrunkLeft())
13226 {
13227
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
129 if(ispitur_75 && ispitbr_75) //Straight right
13228 {
13229 6 return right | flag_pit_irresistable | (ispitur << 8);
13230 }
13231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 else if(ispitur_75)
13232 {
13233 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
13234 }
13235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 else if(ispitbr_75)
13236 {
13237 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
13238 }
13239 123 else return -1;
13240 }
13241 else
13242 {
13243
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1208 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
1232 if(ispitur_50 && ispitbr_50) //Straight right
13244 {
13245
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 16 times.
24 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
13246 }
13247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
1208 else if(ispitur_50)
13248 {
13249 if(DrunkDown() && !ispitur_75) return -1;
13250 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13251 }
13252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
1208 else if(ispitbr_50)
13253 {
13254 if(DrunkUp() && !ispitbr_75) return -1;
13255 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13256 }
13257 }
13258 1208 }
13259 2638 break;
13260 }
13261 case 1:
13262 {
13263
3/4
✓ Branch 0 taken 941 times.
✓ Branch 1 taken 1765 times.
✓ Branch 2 taken 941 times.
✗ Branch 3 not taken.
2706 if(ispitul && ispitul_50) //UL_1
13264 {
13265 if(!ispitul_75 && (DrunkDown() || DrunkRight())) return -1;
13266 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13267 }
13268
4/4
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 2246 times.
✓ Branch 2 taken 444 times.
✓ Branch 3 taken 16 times.
2706 if(ispitur && ispitur_50) //UR_1
13269 {
13270
2/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 if(!ispitur_75 && (DrunkDown() || DrunkLeft())) return -1;
13271 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13272 }
13273
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
2690 if(ispitbl && ispitbl_50) //BL_1
13274 {
13275 if(!ispitbl_75 && (DrunkUp() || DrunkRight())) return -1;
13276 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13277 }
13278
3/4
✓ Branch 0 taken 1129 times.
✓ Branch 1 taken 1561 times.
✓ Branch 2 taken 1129 times.
✗ Branch 3 not taken.
2690 if(ispitbr && ispitbr_50) //BR_1
13279 {
13280 if(!ispitbr_75 && (DrunkUp() || DrunkLeft())) return -1;
13281 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
13282 }
13283 2690 break;
13284 }
13285 }
13286 18211409 }
13287 19199680 return -1;
13288 19200534 }
13289
13290 4304290 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
13291 {
13292 4304290 pitfall();
13293
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4304288 times.
4304290 if(fallclk) return true;
13294 4304288 int32_t val = check_pitslide();
13295 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
13296
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4304282 times.
4304288 if(val == -1)
13297 {
13298 4304282 pit_pulldir = -1;
13299 4304282 pit_pullclk = 0;
13300 4304282 return false;
13301 }
13302 6 int32_t dir = val&0xFF;
13303 6 int32_t cmbid = (val&0xFFFF00)>>8;
13304 6 int32_t sensitivity = combobuf[cmbid].attribytes[2];
13305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
13306 {
13307 pit_pulldir = -1;
13308 pit_pullclk = 0;
13309 return false;
13310 }
13311
4/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 2 times.
6 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
13312 {
13313 2 pit_pulldir = -1;
13314 2 pit_pullclk = 0;
13315 2 return false;
13316 }
13317 4 pit_pulldir = dir;
13318 4 int32_t step = 1;
13319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(sensitivity == 0)
13320 {
13321 4 step = 2;
13322 4 sensitivity = 1;
13323 4 }
13324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(pit_pullclk++ % sensitivity) //No pull this frame
13325 return (val&0x100);
13326
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 4 times.
11 for(; step > 0 && !fallclk; --step)
13327 {
13328
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 switch(dir)
13329 {
13330 case l_up: case l_down: case left:
13331 --x; break;
13332 case r_up: case r_down: case right:
13333 7 ++x; break;
13334 }
13335
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
7 switch(dir)
13336 {
13337 case l_up: case r_up: case up:
13338 --y; break;
13339 case l_down: case r_down: case down:
13340 ++y; break;
13341 }
13342 7 pitfall();
13343 7 }
13344
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 return fallclk || (val&0x100);
13345 4304290 }
13346
13347 4304507 void HeroClass::pitfall()
13348 {
13349
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 4304297 times.
4304507 if(fallclk)
13350 {
13351 210 drop_liftwpn();
13352
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
210 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
13353 //Handle falling
13354
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 3 times.
210 if(!--fallclk)
13355 {
13356 3 int32_t dmg = game->get_hp_per_heart()/4;
13357 3 bool dmg_perc = false;
13358 3 bool warp = false;
13359
13360 3 action=none; FFCore.setHeroAction(none);
13361
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
13362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb)
13363 {
13364 3 dmg = cmb->attributes[0]/10000L;
13365 3 dmg_perc = cmb->usrflags&cflag3;
13366 3 warp = cmb->usrflags&cflag1;
13367 3 }
13368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg) //Damage
13369 {
13370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmg > 0) hclk=48; //IFrames only if damaged, not if healed
13371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
13372 3 }
13373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(warp) //Warp
13374 {
13375 sdir = dir;
13376 if(cmb->usrflags&cflag2) //Direct Warp
13377 {
13378 didpit=true;
13379 pitx=x;
13380 pity=y;
13381 }
13382 dowarp(0,vbound(cmb->attribytes[1],0,3),0);
13383 }
13384 else //Reset to screen entry
13385 {
13386 3 go_respawn_point();
13387 }
13388 3 }
13389 210 }
13390
2/2
✓ Branch 0 taken 321082 times.
✓ Branch 1 taken 3983215 times.
4304297 else if(can_pitfall())
13391 {
13392 3983215 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
13393 3983215 bool ispitbl = ispitfall(x,y+15);
13394 3983215 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
13395 3983215 bool ispitbr = ispitfall(x+15,y+15);
13396 3983215 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
13397
9/10
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 3982734 times.
✓ Branch 2 taken 264 times.
✓ Branch 3 taken 217 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 258 times.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
3983215 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
13398 {
13399
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
13400
3/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
3 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
13401 3 fallclk = PITFALL_FALL_FRAMES;
13402 3 fallCombo = pitctr;
13403 3 action=falling; FFCore.setHeroAction(falling);
13404 3 spins = 0;
13405 3 charging = 0;
13406 3 drop_liftwpn();
13407 3 }
13408 3983215 }
13409 4304507 }
13410
13411 4992709 void HeroClass::movehero()
13412 {
13413
2/4
✓ Branch 0 taken 4992709 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4992709 times.
4992709 if(lstunclock || is_conveyor_stunned) return;
13414 4992709 int32_t xoff=x.getInt()&7;
13415 4992709 int32_t yoff=y.getInt()&7;
13416
2/2
✓ Branch 0 taken 4967566 times.
✓ Branch 1 taken 25143 times.
4992709 if(NO_GRIDLOCK)
13417 {
13418 25143 xoff = 0;
13419 25143 yoff = 0;
13420 25143 }
13421 4992709 int32_t push=pushing;
13422 4992709 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
13423 4992709 pushing=0;
13424 4992709 zfix temp_step(hero_newstep);
13425 4992709 zfix temp_x(x);
13426 4992709 zfix temp_y(y);
13427
13428 4992709 int32_t flippers_id = current_item_id(itype_flippers);
13429 4992709 itemdata const& itm = itemsbuf[flippers_id];
13430 4992709 byte intbtn = byte(itm.misc3&0xFF);
13431 4992709 bool dive_pressed = getIntBtnInput(intbtn, true, true, false, false, true);
13432 4992709 bool eatdive = false;
13433
2/2
✓ Branch 0 taken 4549 times.
✓ Branch 1 taken 4988160 times.
4992709 if(diveclk>0)
13434 {
13435
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4549 if (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM)) diveclk = 0;
13436 4549 --diveclk;
13437
4/8
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1546 times.
✓ Branch 2 taken 3003 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3003 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4549 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG2 && dive_pressed) //Cancellable Diving -V
13438 {
13439 diveclk = itemsbuf[flippers_id].misc2;
13440 eatdive = true;
13441 }
13442 4549 }
13443
4/4
✓ Branch 0 taken 52208 times.
✓ Branch 1 taken 4935952 times.
✓ Branch 2 taken 52137 times.
✓ Branch 3 taken 71 times.
4988160 else if(action == swimming && dive_pressed)
13444 {
13445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & ITEM_FLAG1);
13446 71 bool screen_diving=(tmpscr->flags5&fTOGGLEDIVING) != 0;
13447
13448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(global_diving==screen_diving)
13449 {
13450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13451 71 eatdive = true;
13452 71 }
13453 71 }
13454
2/2
✓ Branch 0 taken 4992638 times.
✓ Branch 1 taken 71 times.
4992709 if(eatdive)
13455 71 getIntBtnInput(intbtn, true, true, false, false, false);
13456
13457
2/2
✓ Branch 0 taken 4932177 times.
✓ Branch 1 taken 60532 times.
4992709 if(action==rafting)
13458 {
13459 60532 do_rafting();
13460
13461
2/2
✓ Branch 0 taken 60371 times.
✓ Branch 1 taken 161 times.
60532 if(action==rafting)
13462 {
13463 60371 return;
13464 }
13465
13466
13467 161 set_respawn_point();
13468 161 trySideviewLadder();
13469 161 }
13470
13471 4932338 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
13472 4932338 int32_t btnwpn = -1;
13473
13474 //&0xFFF removes the "bow & arrows" bitmask
13475 //The Quick Sword is allowed to interrupt attacks.
13476
4/4
✓ Branch 0 taken 4849418 times.
✓ Branch 1 taken 82920 times.
✓ Branch 2 taken 2955645 times.
✓ Branch 3 taken 1893773 times.
4932338 int32_t currentSwordOrWand = (itemsbuf[dowpn].family == itype_wand || itemsbuf[dowpn].family == itype_sword)?dowpn:-1;
13477
8/8
✓ Branch 0 taken 4299937 times.
✓ Branch 1 taken 632401 times.
✓ Branch 2 taken 4295061 times.
✓ Branch 3 taken 4876 times.
✓ Branch 4 taken 164971 times.
✓ Branch 5 taken 472306 times.
✓ Branch 6 taken 33262 times.
✓ Branch 7 taken 604015 times.
4932338 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & ITEM_FLAG5)))
13478 {
13479
2/2
✓ Branch 0 taken 12675 times.
✓ Branch 1 taken 4315648 times.
4328323 if(DrunkrBbtn())
13480 {
13481 12675 btnwpn=getItemFamily(itemsbuf,Bwpn&0xFFF);
13482 12675 dowpn = Bwpn&0xFFF;
13483 12675 directWpn = directItemB;
13484 12675 }
13485
2/2
✓ Branch 0 taken 36314 times.
✓ Branch 1 taken 4279334 times.
4315648 else if(DrunkrAbtn())
13486 {
13487 36314 btnwpn=getItemFamily(itemsbuf,Awpn&0xFFF);
13488 36314 dowpn = Awpn&0xFFF;
13489 36314 directWpn = directItemA;
13490 36314 }
13491
4/4
✓ Branch 0 taken 71669 times.
✓ Branch 1 taken 4207665 times.
✓ Branch 2 taken 71662 times.
✓ Branch 3 taken 7 times.
4279334 else if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) && DrunkrEx1btn())
13492 {
13493 7 btnwpn=getItemFamily(itemsbuf,Xwpn&0xFFF);
13494 7 dowpn = Xwpn&0xFFF;
13495 7 directWpn = directItemX;
13496 7 }
13497
4/4
✓ Branch 0 taken 71662 times.
✓ Branch 1 taken 4207665 times.
✓ Branch 2 taken 71557 times.
✓ Branch 3 taken 105 times.
4279327 else if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) && DrunkrEx2btn())
13498 {
13499 105 btnwpn=getItemFamily(itemsbuf,Ywpn&0xFFF);
13500 105 dowpn = Ywpn&0xFFF;
13501 105 directWpn = directItemY;
13502 105 }
13503
13504
1/2
✓ Branch 0 taken 4328323 times.
✗ Branch 1 not taken.
4328323 if(directWpn > 255) directWpn = 0;
13505
13506 // The Quick Sword only allows repeated sword or wand swings.
13507
7/8
✓ Branch 0 taken 4295061 times.
✓ Branch 1 taken 33262 times.
✓ Branch 2 taken 33262 times.
✓ Branch 3 taken 4295061 times.
✓ Branch 4 taken 32749 times.
✓ Branch 5 taken 513 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4295574 times.
4328323 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
13508 32749 btnwpn=-1;
13509 4328323 }
13510
13511
2/2
✓ Branch 0 taken 317704 times.
✓ Branch 1 taken 4614634 times.
4932338 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
13512
11/12
✓ Branch 0 taken 4661874 times.
✓ Branch 1 taken 270464 times.
✓ Branch 2 taken 4481233 times.
✓ Branch 3 taken 180641 times.
✓ Branch 4 taken 4406617 times.
✓ Branch 5 taken 74616 times.
✓ Branch 6 taken 4369242 times.
✓ Branch 7 taken 37375 times.
✓ Branch 8 taken 34877 times.
✓ Branch 9 taken 4334365 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 34877 times.
4932338 if(can_attack() && (swordid > -1 && itemsbuf[swordid].family==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
13513 {
13514
2/2
✓ Branch 0 taken 1566 times.
✓ Branch 1 taken 33311 times.
34877 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
13515
5/6
✓ Branch 0 taken 34875 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 34860 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
34877 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & ITEM_FLAG6)))
13516 {
13517
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34860 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
34860 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
13518 {
13519 paymagiccost(attackid,true);
13520 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
13521 }
13522 34860 SetAttack();
13523 34860 attack=wSword;
13524
13525 34860 attackclk=0;
13526
2/2
✓ Branch 0 taken 1551 times.
✓ Branch 1 taken 33309 times.
34860 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x.getInt()));
13527
13528
2/10
✓ Branch 0 taken 34860 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34860 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
34860 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13529 {
13530 if(!checkmagiccost(dowpn))
13531 {
13532 item_error();
13533 }
13534 else
13535 {
13536 //clear the item script stack for a new script
13537
13538 ri = &(itemScriptData[dowpn]);
13539 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13540 ri->Clear();
13541 //itemScriptData[(dowpn & 0xFFF)].Clear();
13542 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13543 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13544 item_doscript[dowpn] = 1;
13545 itemscriptInitialised[dowpn] = 0;
13546 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13547 did_scripta=true;
13548 }
13549 }
13550 34860 }
13551 else
13552 {
13553 17 item_error();
13554 }
13555 34877 }
13556 else
13557 {
13558 4897461 did_scripta=false;
13559 }
13560
13561
7/10
✓ Branch 0 taken 4876046 times.
✓ Branch 1 taken 56292 times.
✓ Branch 2 taken 4876046 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4876046 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4876046 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 214 times.
✓ Branch 9 taken 4875832 times.
4932338 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
13562 {
13563
4/4
✓ Branch 0 taken 775050 times.
✓ Branch 1 taken 4100782 times.
✓ Branch 2 taken 775045 times.
✓ Branch 3 taken 5 times.
4875832 if(DrunkUp() && canSideviewLadder())
13564 {
13565 5 setOnSideviewLadder(true);
13566 5 }
13567
3/4
✓ Branch 0 taken 636477 times.
✓ Branch 1 taken 4239350 times.
✓ Branch 2 taken 636477 times.
✗ Branch 3 not taken.
4875827 else if(DrunkDown() && canSideviewLadder(true))
13568 {
13569 y+=1;
13570 setOnSideviewLadder(true);
13571 }
13572 4875832 }
13573
13574 4932338 int32_t wx=x;
13575 4932338 int32_t wy=y;
13576
5/6
✓ Branch 0 taken 3273031 times.
✓ Branch 1 taken 1659307 times.
✓ Branch 2 taken 219 times.
✓ Branch 3 taken 4932119 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 219 times.
4932338 if((action==none || action==walking) && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13577 {
13578
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219 if((xoff==0)||diagonalMovement)
13579 {
13580
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 180 times.
219 if(DrunkUp()) dir=up;
13581
1/2
✓ Branch 0 taken 219 times.
✗ Branch 1 not taken.
219 if(DrunkDown()) dir=down;
13582 219 }
13583
13584
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219 if((yoff==0)||diagonalMovement)
13585 {
13586
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 23 times.
219 if(DrunkLeft()) dir=left;
13587
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 29 times.
219 if(DrunkRight()) dir=right;
13588 219 }
13589 219 }
13590
13591
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1123015 times.
✓ Branch 2 taken 935121 times.
✓ Branch 3 taken 1371398 times.
✓ Branch 4 taken 1502804 times.
4932338 switch(dir)
13592 {
13593 case up:
13594 1123015 wy-=16;
13595 1123015 break;
13596
13597 case down:
13598 935121 wy+=16;
13599 935121 break;
13600
13601 case left:
13602 1371398 wx-=16;
13603 1371398 break;
13604
13605 case right:
13606 1502804 wx+=16;
13607 1502804 break;
13608 }
13609
13610 4932338 do_lens();
13611
13612 4932338 WalkflagInfo info;
13613
13614 4932338 bool no_jinx = true;
13615
7/8
✓ Branch 0 taken 4661874 times.
✓ Branch 1 taken 270464 times.
✓ Branch 2 taken 13719 times.
✓ Branch 3 taken 4648155 times.
✓ Branch 4 taken 13719 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1076 times.
✓ Branch 7 taken 12643 times.
4932338 if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
13616 {
13617 12643 bool paidmagic = false;
13618
6/8
✓ Branch 0 taken 11435 times.
✓ Branch 1 taken 1208 times.
✓ Branch 2 taken 489 times.
✓ Branch 3 taken 719 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 489 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1208 times.
12643 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_wand : false) : current_item(itype_wand)))
13619 {
13620
2/2
✓ Branch 0 taken 489 times.
✓ Branch 1 taken 719 times.
1208 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
13621 1208 no_jinx = checkitem_jinx(attackid);
13622
3/8
✓ Branch 0 taken 1208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1208 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1208 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1208 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13623 {
13624
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
13625 paymagiccost(attackid,true);
13626 misc_internal_hero_flags |= LF_PAID_WAND_COST;
13627 }
13628 1208 SetAttack();
13629 1208 attack=wWand;
13630 1208 attackclk=0;
13631 1208 }
13632 else
13633 {
13634 item_error();
13635 }
13636 1208 }
13637
4/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 11338 times.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 97 times.
11532 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
13638
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 95 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
97 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_hammer : false) : current_item(itype_hammer)))
13639 {
13640 97 no_jinx = checkitem_jinx(dowpn);
13641
3/6
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 97 times.
97 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
13642 {
13643 item_error();
13644 }
13645 else
13646 {
13647 97 paymagiccost(dowpn);
13648 97 paidmagic = true;
13649 97 SetAttack();
13650 97 attack=wHammer;
13651
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 95 times.
97 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
13652 97 attackclk=0;
13653 }
13654 97 }
13655
4/6
✓ Branch 0 taken 1072 times.
✓ Branch 1 taken 10266 times.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1072 times.
12410 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
13656
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1072 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 904 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
1072 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_candle : false) : current_item(itype_candle)))
13657 {
13658 //checkbunny handled where magic cost is paid
13659
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 904 times.
1072 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
13660 1072 no_jinx = checkitem_jinx(attackid);
13661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1072 times.
1072 if(no_jinx)
13662 {
13663 1072 SetAttack();
13664 1072 attack=wFire;
13665 1072 attackclk=0;
13666 1072 }
13667 1072 }
13668
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 10262 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
10270 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
13669
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].family==itype_cbyrna : false) : current_item(itype_cbyrna)))
13670 {
13671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
13672 4 no_jinx = checkitem_jinx(attackid);
13673
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & ITEM_FLAG6)) || checkmagiccost(attackid)))
13674 {
13675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((itemsbuf[attackid].flags & ITEM_FLAG6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
13676 paymagiccost(attackid,true);
13677 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
13678 }
13679 4 SetAttack();
13680 4 attack=wCByrna;
13681 4 attackclk=0;
13682 4 }
13683 else
13684 {
13685 item_error();
13686 }
13687 4 }
13688
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10262 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10262 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
13689 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].family==itype_bugnet) : current_item(itype_bugnet)))
13690 {
13691 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
13692 no_jinx = checkitem_jinx(attackid);
13693 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
13694 {
13695 paymagiccost(attackid);
13696 SetAttack();
13697 attack = wBugNet;
13698 attackclk = 0;
13699 sfx(itemsbuf[attackid].usesound);
13700 }
13701 else
13702 {
13703 item_error();
13704 }
13705 }
13706 else
13707 {
13708
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 10185 times.
10262 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
13709 10262 no_jinx = checkitem_jinx(itmid);
13710
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 10248 times.
10262 if(no_jinx)
13711 {
13712 10248 paidmagic = startwpn(itmid);
13713
13714
2/2
✓ Branch 0 taken 8539 times.
✓ Branch 1 taken 1709 times.
10248 if(paidmagic)
13715 {
13716
5/10
✓ Branch 0 taken 8539 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8539 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8539 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8539 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 8539 times.
8539 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
13717 {
13718 ;
13719 }
13720 else
13721 {
13722 8539 SetAttack();
13723 8539 attackclk=0;
13724 8539 attack=none;
13725
13726
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 7374 times.
8539 if(btnwpn==itype_brang)
13727 {
13728 7374 attack=wBrang;
13729 7374 }
13730 }
13731 8539 }
13732 else
13733 {
13734 // Weapon not started: directWpn should be reset to prev. value.
13735 1709 directWpn = olddirectwpn;
13736 }
13737 10248 }
13738 }
13739
13740
8/12
✓ Branch 0 taken 12643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12629 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 866 times.
✓ Branch 5 taken 11763 times.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
12643 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(item_doscript[dowpn] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)))
13741 {
13742
3/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 800 times.
800 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
13743 {
13744 item_error();
13745 }
13746 else
13747 {
13748 // Only charge for magic if item's magic cost wasn't already charged
13749 // for the item's main use.
13750
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 795 times.
800 if(!paidmagic && attack!=wWand)
13751 795 paymagiccost(dowpn);
13752 //clear the item script stack for a new script
13753 //itemScriptData[(dowpn & 0xFFF)].Clear();
13754 800 ri = &(itemScriptData[dowpn]);
13755
2/2
✓ Branch 0 taken 819200 times.
✓ Branch 1 taken 800 times.
820000 for ( int32_t q = 0; q < 1024; q++ ) item_stack[dowpn][q] = 0xFFFF;
13756 800 ri->Clear();
13757 //for ( int32_t q = 0; q < 1024; q++ ) item_stack[(dowpn & 0xFFF)][q] = 0;
13758 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn & 0xFFF);
13759 800 item_doscript[dowpn] = 1;
13760 800 itemscriptInitialised[dowpn] = 0;
13761 800 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[dowpn].script, dowpn);
13762 800 did_scriptb=true;
13763 }
13764 800 }
13765
13766
7/12
✓ Branch 0 taken 12629 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 12629 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12629 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12629 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12629 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 12629 times.
12643 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
13767 {
13768 return;
13769 }
13770
2/2
✓ Branch 0 taken 12629 times.
✓ Branch 1 taken 14 times.
12643 if(!no_jinx)
13771 14 did_scriptb = false;
13772 12643 }
13773 else
13774 {
13775 4919695 did_scriptb=false;
13776 }
13777
13778
5/6
✓ Branch 0 taken 4300449 times.
✓ Branch 1 taken 631889 times.
✓ Branch 2 taken 4249792 times.
✓ Branch 3 taken 50657 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4249792 times.
4932338 if(attackclk || action==attacking || action==sideswimattacking)
13779 {
13780
13781
4/8
✓ Branch 0 taken 50657 times.
✓ Branch 1 taken 631889 times.
✓ Branch 2 taken 50657 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 50657 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
682546 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_bit(quest_rules,qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
13782 {
13783 if((xoff==0)||diagonalMovement)
13784 {
13785 if(DrunkUp()) dir=up;
13786 if(DrunkDown()) dir=down;
13787 }
13788
13789 if((yoff==0)||diagonalMovement)
13790 {
13791 if(DrunkLeft()) dir=left;
13792 if(DrunkRight()) dir=right;
13793 }
13794 }
13795
13796 682546 bool attacked = doattack();
13797
13798 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
13799
10/12
✓ Branch 0 taken 680909 times.
✓ Branch 1 taken 1637 times.
✓ Branch 2 taken 480486 times.
✓ Branch 3 taken 200423 times.
✓ Branch 4 taken 91596 times.
✓ Branch 5 taken 388890 times.
✓ Branch 6 taken 89920 times.
✓ Branch 7 taken 1676 times.
✓ Branch 8 taken 89920 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 89920 times.
682546 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
13800 {
13801
4/4
✓ Branch 0 taken 38840 times.
✓ Branch 1 taken 51080 times.
✓ Branch 2 taken 4695 times.
✓ Branch 3 taken 34145 times.
89920 if((xoff==0)||diagonalMovement)
13802 {
13803
2/2
✓ Branch 0 taken 50538 times.
✓ Branch 1 taken 5237 times.
55775 if(DrunkUp()) dir=up;
13804
13805
2/2
✓ Branch 0 taken 50215 times.
✓ Branch 1 taken 5560 times.
55775 if(DrunkDown()) dir=down;
13806 55775 }
13807
13808
4/4
✓ Branch 0 taken 28918 times.
✓ Branch 1 taken 61002 times.
✓ Branch 2 taken 3273 times.
✓ Branch 3 taken 25645 times.
89920 if((yoff==0)||diagonalMovement)
13809 {
13810
2/2
✓ Branch 0 taken 57168 times.
✓ Branch 1 taken 7107 times.
64275 if(DrunkLeft()) dir=left;
13811
13812
2/2
✓ Branch 0 taken 57335 times.
✓ Branch 1 taken 6940 times.
64275 if(DrunkRight()) dir=right;
13813 64275 }
13814 89920 }
13815
13816
9/10
✓ Branch 0 taken 634371 times.
✓ Branch 1 taken 48175 times.
✓ Branch 2 taken 632450 times.
✓ Branch 3 taken 1921 times.
✓ Branch 4 taken 632015 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 627800 times.
✓ Branch 7 taken 4215 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 627800 times.
682546 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
13817 {
13818 627800 return;
13819 }
13820
2/2
✓ Branch 0 taken 6571 times.
✓ Branch 1 taken 48175 times.
54746 else if(!attacked)
13821 {
13822 // Spin attack - change direction
13823
3/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 47927 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 248 times.
48175 if(spins>1 && attack != wHammer)
13824 {
13825 248 spins--;
13826
13827
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 45 times.
248 if(spins%5==0)
13828 {
13829
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
13830 45 sfx(itemsbuf[id].usesound,pan(x.getInt()));
13831 45 }
13832 248 attackclk=1;
13833
13834
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 62 times.
248 switch(dir)
13835 {
13836 case up:
13837 62 dir=left;
13838 62 break;
13839
13840 case right:
13841 62 dir=up;
13842 62 break;
13843
13844 case down:
13845 62 dir=right;
13846 62 break;
13847
13848 case left:
13849 62 dir=down;
13850 62 break;
13851 }
13852
13853 248 return;
13854 }
13855 else
13856 {
13857 47927 spins=0;
13858 }
13859
13860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47927 times.
47927 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
13861 47927 else {action=none; FFCore.setHeroAction(none);}
13862 47927 attackclk=0;
13863 47927 charging=0;
13864 47927 }
13865 54498 }
13866
13867
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4304287 times.
4304290 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
13868 3 return;
13869
13870
2/2
✓ Branch 0 taken 1764634 times.
✓ Branch 1 taken 2539653 times.
4304287 if(action==walking) //still walking
13871 {
13872
9/10
✓ Branch 0 taken 1925177 times.
✓ Branch 1 taken 614476 times.
✓ Branch 2 taken 1435301 times.
✓ Branch 3 taken 489876 times.
✓ Branch 4 taken 766548 times.
✓ Branch 5 taken 668753 times.
✓ Branch 6 taken 32889 times.
✓ Branch 7 taken 733659 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32889 times.
2539653 if(!DrunkUp() && !DrunkDown() && !DrunkLeft() && !DrunkRight() && !autostep)
13873 {
13874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32889 times.
32889 if(attackclk>0) SetAttack();
13875 32889 else {action = none; FFCore.setHeroAction(none);}
13876 32889 hero_count=-1;
13877 32889 return;
13878 }
13879
13880 2506764 autostep=false;
13881
13882
3/4
✓ Branch 0 taken 2227307 times.
✓ Branch 1 taken 279457 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2227307 times.
2506764 if(!(diagonalMovement || NO_GRIDLOCK))
13883 {
13884
2/4
✓ Branch 0 taken 2227307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2227307 times.
2227307 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
13885 {
13886 if(dir==up&&yoff)
13887 {
13888 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
13889 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
13890 execute(info);
13891
13892 if(!info.isUnwalkable())
13893 {
13894 move(up);
13895 }
13896 else
13897 {
13898 action=none; FFCore.setHeroAction(none);
13899 }
13900
13901 return;
13902 }
13903
13904 if(dir==down&&yoff)
13905 {
13906 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
13907 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
13908 execute(info);
13909
13910 if(!info.isUnwalkable())
13911 {
13912 move(down);
13913 }
13914 else
13915 {
13916 action=none; FFCore.setHeroAction(none);
13917 }
13918
13919 return;
13920 }
13921
13922 if(dir==left&&xoff)
13923 {
13924 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
13925 execute(info);
13926
13927 if(!info.isUnwalkable())
13928 {
13929 move(left);
13930 }
13931 else
13932 {
13933 action=none; FFCore.setHeroAction(none);
13934 }
13935
13936 return;
13937 }
13938
13939 if(dir==right&&xoff)
13940 {
13941 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
13942 execute(info);
13943
13944 if(!info.isUnwalkable())
13945 {
13946 move(right);
13947 }
13948 else
13949 {
13950 action=none; FFCore.setHeroAction(none);
13951 }
13952
13953 return;
13954 }
13955 }
13956 else
13957 {
13958
4/4
✓ Branch 0 taken 517036 times.
✓ Branch 1 taken 1710271 times.
✓ Branch 2 taken 85160 times.
✓ Branch 3 taken 431876 times.
2227307 if(dir==up&&yoff)
13959 {
13960 431876 while(true)
13961 {
13962 431876 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
13963 431876 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
13964 431876 execute(info);
13965
13966
2/2
✓ Branch 0 taken 1575 times.
✓ Branch 1 taken 430301 times.
431876 if(!info.isUnwalkable())
13967 {
13968 430301 hero_newstep = temp_step;
13969 430301 x = temp_x;
13970 430301 y = temp_y;
13971 430301 move(up);
13972 430301 return;
13973 }
13974 //Could not move, try moving less
13975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 if(temp_y != int32_t(temp_y))
13976 {
13977 temp_y = floor((double)temp_y);
13978 continue;
13979 }
13980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1575 times.
1575 else if(temp_step > 1)
13981 {
13982 if(temp_step != int32_t(temp_step)) //floor
13983 temp_step = floor((double)temp_step);
13984 else --temp_step;
13985 continue;
13986 }
13987 else //Can't move less, stop moving
13988 {
13989 1575 action=none; FFCore.setHeroAction(none);
13990 }
13991 1575 return;
13992 }
13993 }
13994
13995
4/4
✓ Branch 0 taken 415866 times.
✓ Branch 1 taken 1379565 times.
✓ Branch 2 taken 69073 times.
✓ Branch 3 taken 346793 times.
1795431 if(dir==down&&yoff)
13996 {
13997 346793 while(true)
13998 {
13999 346798 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
14000 346798 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
14001 346798 execute(info);
14002
14003
2/2
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 345526 times.
346798 if(!info.isUnwalkable())
14004 {
14005 345526 hero_newstep = temp_step;
14006 345526 x = temp_x;
14007 345526 y = temp_y;
14008 345526 move(down);
14009 345526 return;
14010 }
14011 //Could not move, try moving less
14012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1272 times.
1272 if(temp_y != int32_t(temp_y))
14013 {
14014 temp_y = floor((double)temp_y);
14015 continue;
14016 }
14017
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1267 times.
1272 else if(temp_step > 1)
14018 {
14019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(temp_step != int32_t(temp_step)) //floor
14020 5 temp_step = floor((double)temp_step);
14021 else --temp_step;
14022 5 continue;
14023 }
14024 else //Can't move less, stop moving
14025 {
14026 1267 action=none; FFCore.setHeroAction(none);
14027 }
14028 1267 return;
14029 }
14030 }
14031
14032
4/4
✓ Branch 0 taken 622471 times.
✓ Branch 1 taken 826167 times.
✓ Branch 2 taken 104488 times.
✓ Branch 3 taken 517983 times.
1448638 if(dir==left&&xoff)
14033 {
14034 517983 while(true)
14035 {
14036 517983 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
14037 517983 execute(info);
14038
14039
2/2
✓ Branch 0 taken 1199 times.
✓ Branch 1 taken 516784 times.
517983 if(!info.isUnwalkable())
14040 {
14041 516784 hero_newstep = temp_step;
14042 516784 x = temp_x;
14043 516784 y = temp_y;
14044 516784 move(left);
14045 516784 return;
14046 }
14047 //Could not move, try moving less
14048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1199 times.
1199 if(temp_x != int32_t(temp_x))
14049 {
14050 temp_x = floor((double)temp_x);
14051 continue;
14052 }
14053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1199 times.
1199 else if(temp_step > 1)
14054 {
14055 if(temp_step != int32_t(temp_step)) //floor
14056 temp_step = floor((double)temp_step);
14057 else --temp_step;
14058 continue;
14059 }
14060 else //Can't move less, stop moving
14061 {
14062 1199 action=none; FFCore.setHeroAction(none);
14063 }
14064 1199 return;
14065 }
14066 }
14067
14068
4/4
✓ Branch 0 taken 671934 times.
✓ Branch 1 taken 258721 times.
✓ Branch 2 taken 112505 times.
✓ Branch 3 taken 559429 times.
930655 if(dir==right&&xoff)
14069 {
14070 559429 while(true)
14071 {
14072 559435 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
14073 559435 execute(info);
14074
14075
2/2
✓ Branch 0 taken 1227 times.
✓ Branch 1 taken 558208 times.
559435 if(!info.isUnwalkable())
14076 {
14077 558208 hero_newstep = temp_step;
14078 558208 x = temp_x;
14079 558208 y = temp_y;
14080 558208 move(right);
14081 558208 return;
14082 }
14083 //Could not move, try moving less
14084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1227 times.
1227 if(temp_x != int32_t(temp_x))
14085 {
14086 temp_x = floor((double)temp_x);
14087 continue;
14088 }
14089
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1221 times.
1227 else if(temp_step > 1)
14090 {
14091
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(temp_step != int32_t(temp_step)) //floor
14092 6 temp_step = floor((double)temp_step);
14093 else --temp_step;
14094 6 continue;
14095 }
14096 else //Can't move less, stop moving
14097 {
14098 1221 action=none; FFCore.setHeroAction(none);
14099 }
14100 1221 return;
14101 }
14102 }
14103 }
14104 371226 }
14105
14106 650683 } // endif (action==walking)
14107
14108
16/24
✓ Branch 0 taken 2359025 times.
✓ Branch 1 taken 56292 times.
✓ Branch 2 taken 2359025 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2359025 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2359025 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2359025 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2359025 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2359025 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2359025 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2359025 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2357104 times.
✓ Branch 19 taken 1921 times.
✓ Branch 20 taken 2356669 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 76031 times.
✓ Branch 23 taken 2280638 times.
2415317 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
14109 {
14110 2280638 action=none; FFCore.setHeroAction(none);
14111 2280638 }
14112
14113
2/2
✓ Branch 0 taken 601984 times.
✓ Branch 1 taken 1813333 times.
2415317 if(diagonalMovement)
14114 {
14115
5/5
✓ Branch 0 taken 223539 times.
✓ Branch 1 taken 54948 times.
✓ Branch 2 taken 41245 times.
✓ Branch 3 taken 129788 times.
✓ Branch 4 taken 152464 times.
601984 switch(holddir)
14116 {
14117 case up:
14118
2/2
✓ Branch 0 taken 53192 times.
✓ Branch 1 taken 1756 times.
54948 if(!Up())
14119 {
14120 1756 holddir=-1;
14121 1756 }
14122
14123 54948 break;
14124
14125 case down:
14126
2/2
✓ Branch 0 taken 39666 times.
✓ Branch 1 taken 1579 times.
41245 if(!Down())
14127 {
14128 1579 holddir=-1;
14129 1579 }
14130
14131 41245 break;
14132
14133 case left:
14134
2/2
✓ Branch 0 taken 125897 times.
✓ Branch 1 taken 3891 times.
129788 if(!Left())
14135 {
14136 3891 holddir=-1;
14137 3891 }
14138
14139 129788 break;
14140
14141 case right:
14142
2/2
✓ Branch 0 taken 148185 times.
✓ Branch 1 taken 4279 times.
152464 if(!Right())
14143 {
14144 4279 holddir=-1;
14145 4279 }
14146
14147 152464 break;
14148
14149 default:
14150 223539 break;
14151 } //end switch
14152
14153
3/4
✓ Branch 0 taken 463429 times.
✓ Branch 1 taken 138555 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 463429 times.
601984 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
14154 {
14155 138555 walkable = false;
14156
6/6
✓ Branch 0 taken 24477 times.
✓ Branch 1 taken 114078 times.
✓ Branch 2 taken 23730 times.
✓ Branch 3 taken 747 times.
✓ Branch 4 taken 6913 times.
✓ Branch 5 taken 16817 times.
138555 if(DrunkUp()&&(holddir==-1||holddir==up))
14157 {
14158
4/8
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 17478 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17564 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14159 {
14160 }
14161 else
14162 {
14163
4/10
✓ Branch 0 taken 17564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17564 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17564 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 17564 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
17564 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14164 {
14165 17564 dir=up;
14166 17564 }
14167
14168 17564 holddir=up;
14169
14170
4/4
✓ Branch 0 taken 2219 times.
✓ Branch 1 taken 15345 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 2214 times.
17564 if(DrunkRight()&&shiftdir!=left)
14171 {
14172 2214 shiftdir=right;
14173
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2214 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14174
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2214 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14175 2214 }
14176
4/4
✓ Branch 0 taken 2221 times.
✓ Branch 1 taken 13129 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2219 times.
15350 else if(DrunkLeft()&&shiftdir!=right)
14177 {
14178 2219 shiftdir=left;
14179
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2219 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14180
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2219 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2219 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14181 2219 }
14182 else
14183 {
14184 13131 shiftdir=-1;
14185 }
14186
14187 //walkable if Ladder can be placed or is already placed vertically
14188
9/20
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 17370 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 55 times.
✓ Branch 13 taken 139 times.
✓ Branch 14 taken 55 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 55 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 55 times.
17564 if(isSideViewHero() && !toogam && (!get_bit(quest_rules, qr_OLD_LADDER_ITEM_SIDEVIEW) || !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up))) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14189 {
14190 55 walkable=false;
14191 55 }
14192 else
14193 {
14194 17509 do
14195 {
14196 20229 zfix ty = y - hero_newstep;
14197 40458 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14198 20229 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14199
14200
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 20168 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
20229 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14201 {
14202 61 info = info || walkflag(x, zfix(0), 2, up);
14203 61 info = info || walkflag(x+15, zfix(0), 1, up);
14204 61 }
14205 20229 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14206
14207 20229 execute(info);
14208
14209
2/2
✓ Branch 0 taken 5245 times.
✓ Branch 1 taken 14984 times.
20229 if(info.isUnwalkable())
14210 {
14211
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 5050 times.
5245 if(y != y.getInt())
14212 {
14213 195 y.doRound();
14214 195 }
14215
2/2
✓ Branch 0 taken 2525 times.
✓ Branch 1 taken 2525 times.
5050 else if(hero_newstep > 1)
14216 {
14217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2525 times.
2525 if(hero_newstep != int32_t(hero_newstep)) //floor
14218 2525 hero_newstep = floor((double)hero_newstep);
14219 else --hero_newstep;
14220 2525 }
14221 else
14222 2525 break;
14223 2720 }
14224 14984 else walkable = true;
14225
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 14984 times.
17704 }
14226 17704 while(!walkable);
14227 }
14228
14229 17564 int32_t s=shiftdir;
14230
14231
4/6
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 17478 times.
✓ Branch 2 taken 86 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86 times.
✗ Branch 5 not taken.
17564 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14232 {
14233 shiftdir=-1;
14234 }
14235 else
14236 {
14237
2/2
✓ Branch 0 taken 2219 times.
✓ Branch 1 taken 15345 times.
17564 if(s==left)
14238 {
14239 2219 do
14240 {
14241 2631 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14242
14243 2631 execute(info);
14244
14245
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 1843 times.
2631 if(info.isUnwalkable())
14246 {
14247
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 752 times.
788 if(x != x.getInt())
14248 {
14249 36 x.doRound();
14250 36 }
14251
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 376 times.
752 else if(hero_newstep_diag > 1)
14252 {
14253
1/2
✓ Branch 0 taken 376 times.
✗ Branch 1 not taken.
376 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14254 376 hero_newstep_diag.doFloor();
14255 else --hero_newstep_diag;
14256 376 }
14257 else
14258 376 shiftdir = -1;
14259 788 }
14260
2/2
✓ Branch 0 taken 1574 times.
✓ Branch 1 taken 269 times.
1843 else if(walkable)
14261 {
14262 1574 do
14263 {
14264 1578 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
14265 1578 execute(info);
14266
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1571 times.
1578 if(info.isUnwalkable())
14267 {
14268
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6 times.
7 if(x != x.getInt())
14269 {
14270 1 x.doRound();
14271 1 }
14272
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14273 {
14274
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14275 3 hero_newstep_diag.doFloor();
14276 else --hero_newstep_diag;
14277 3 }
14278 else
14279 3 shiftdir = -1;
14280 7 }
14281 1571 else break;
14282
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 }
14283 7 while(shiftdir != -1);
14284 1574 break;
14285 }
14286 269 else break;
14287
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 376 times.
788 }
14288 788 while(shiftdir != -1);
14289 2219 }
14290
2/2
✓ Branch 0 taken 13131 times.
✓ Branch 1 taken 2214 times.
15345 else if(s==right)
14291 {
14292 2214 do
14293 {
14294 2538 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14295
14296 2538 execute(info);
14297
14298
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1926 times.
2538 if(info.isUnwalkable())
14299 {
14300
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 576 times.
612 if(x != x.getInt())
14301 {
14302 36 x.doRound();
14303 36 }
14304
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 288 times.
576 else if(hero_newstep_diag > 1)
14305 {
14306
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14307 288 hero_newstep_diag.doFloor();
14308 else --hero_newstep_diag;
14309 288 }
14310 else
14311 288 shiftdir = -1;
14312 612 }
14313
2/2
✓ Branch 0 taken 1592 times.
✓ Branch 1 taken 334 times.
1926 else if(walkable)
14314 {
14315 1592 do
14316 {
14317 1598 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
14318 1598 execute(info);
14319
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1587 times.
1598 if(info.isUnwalkable())
14320 {
14321
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14322 {
14323 1 x.doRound();
14324 1 }
14325
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14326 {
14327
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14328 5 hero_newstep_diag.doFloor();
14329 else --hero_newstep_diag;
14330 5 }
14331 else
14332 5 shiftdir = -1;
14333 11 }
14334 1587 else break;
14335
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14336 11 while(shiftdir != -1);
14337 1592 break;
14338 }
14339 334 else break;
14340
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 288 times.
612 }
14341 612 while(shiftdir != -1);
14342 2214 }
14343 }
14344
14345 17564 move(up);
14346 17564 shiftdir=s;
14347
14348
2/2
✓ Branch 0 taken 14984 times.
✓ Branch 1 taken 2580 times.
17564 if(!walkable)
14349 {
14350
2/2
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 1906 times.
2580 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14351 {
14352 1906 x = x.getInt();
14353 1906 y = y.getInt();
14354
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1906 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1906 times.
✓ Branch 4 taken 1600 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 116 times.
✓ Branch 7 taken 1790 times.
2212 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14355
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 306 times.
✓ Branch 4 taken 131 times.
✓ Branch 5 taken 175 times.
306 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14356
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 175 times.
✓ Branch 2 taken 175 times.
✗ Branch 3 not taken.
175 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14357 {
14358
5/8
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 116 times.
116 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
14359 116 sprite::move((zfix)-1,(zfix)0);
14360 116 }
14361 else
14362 {
14363
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1790 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1790 times.
✓ Branch 4 taken 190 times.
✓ Branch 5 taken 1600 times.
✓ Branch 6 taken 132 times.
✓ Branch 7 taken 1658 times.
3390 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14364
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1600 times.
✓ Branch 2 taken 1600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1468 times.
✓ Branch 5 taken 132 times.
1600 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
14365
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
14366 {
14367
4/8
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 132 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 132 times.
132 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
14368 132 sprite::move((zfix)1,(zfix)0);
14369 132 }
14370 else
14371 {
14372 1658 pushing=push+1;
14373 }
14374 }
14375 1906 }
14376 else
14377 {
14378 674 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14379 }
14380 2580 }
14381
14382 17564 return;
14383 }
14384 }
14385
14386
6/6
✓ Branch 0 taken 23948 times.
✓ Branch 1 taken 97043 times.
✓ Branch 2 taken 23116 times.
✓ Branch 3 taken 832 times.
✓ Branch 4 taken 17238 times.
✓ Branch 5 taken 5878 times.
120991 if(DrunkDown()&&(holddir==-1||holddir==down))
14387 {
14388
4/8
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 17937 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
18070 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14389 {
14390 }
14391 else
14392 {
14393
4/10
✓ Branch 0 taken 18070 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18070 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18070 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 18070 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
18070 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR)))
14394 {
14395 18070 dir=down;
14396 18070 }
14397
14398 18070 holddir=down;
14399
14400
4/4
✓ Branch 0 taken 3002 times.
✓ Branch 1 taken 15068 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3000 times.
18070 if(DrunkRight()&&shiftdir!=left)
14401 {
14402 3000 shiftdir=right;
14403
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3000 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
14404
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3000 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
14405 3000 }
14406
4/4
✓ Branch 0 taken 2901 times.
✓ Branch 1 taken 12169 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2900 times.
15070 else if(DrunkLeft()&&shiftdir!=right)
14407 {
14408 2900 shiftdir=left;
14409
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2900 if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
14410
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2900 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
14411 2900 }
14412 else
14413 {
14414 12170 shiftdir=-1;
14415 }
14416
14417 //bool walkable;
14418
7/12
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 17410 times.
✓ Branch 2 taken 660 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 660 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 660 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 660 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 660 times.
18070 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
14419 {
14420 660 walkable=false;
14421 660 }
14422 else
14423 {
14424 17410 do
14425 {
14426 19691 info = walkflag(x,15+(y+hero_newstep),2,down);
14427
14428
2/2
✓ Branch 0 taken 11725 times.
✓ Branch 1 taken 7966 times.
19691 if(x.getFloor() & 7)
14429 11725 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
14430 else
14431 7966 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
14432
14433 19691 execute(info);
14434
14435
2/2
✓ Branch 0 taken 4319 times.
✓ Branch 1 taken 15372 times.
19691 if(info.isUnwalkable())
14436 {
14437
2/2
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 4093 times.
4319 if(y != y.getInt())
14438 {
14439 226 y.doRound();
14440 226 }
14441
2/2
✓ Branch 0 taken 2055 times.
✓ Branch 1 taken 2038 times.
4093 else if(hero_newstep > 1)
14442 {
14443
1/2
✓ Branch 0 taken 2055 times.
✗ Branch 1 not taken.
2055 if(hero_newstep != int32_t(hero_newstep)) //floor
14444 2055 hero_newstep = floor((double)hero_newstep);
14445 else --hero_newstep;
14446 2055 }
14447 else
14448 2038 break;
14449 2281 }
14450 15372 else walkable = true;
14451
2/2
✓ Branch 0 taken 2281 times.
✓ Branch 1 taken 15372 times.
17653 }
14452 17653 while(!walkable);
14453 }
14454
14455 18070 int32_t s=shiftdir;
14456
14457
4/6
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 17937 times.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
18070 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
14458 {
14459 shiftdir=-1;
14460 }
14461 else
14462 {
14463
2/2
✓ Branch 0 taken 2900 times.
✓ Branch 1 taken 15170 times.
18070 if(s==left)
14464 {
14465 2900 do
14466 {
14467 3313 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
14468
14469 3313 execute(info);
14470
14471
2/2
✓ Branch 0 taken 772 times.
✓ Branch 1 taken 2541 times.
3313 if(info.isUnwalkable())
14472 {
14473
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 718 times.
772 if(x != x.getInt())
14474 {
14475 54 x.doRound();
14476 54 }
14477
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 359 times.
718 else if(hero_newstep_diag > 1)
14478 {
14479
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14480 359 hero_newstep_diag.doFloor();
14481 else --hero_newstep_diag;
14482 359 }
14483 else
14484 359 shiftdir = -1;
14485 772 }
14486
2/2
✓ Branch 0 taken 2049 times.
✓ Branch 1 taken 492 times.
2541 else if(walkable)
14487 {
14488 2049 do
14489 {
14490 2056 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
14491 2056 execute(info);
14492
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 2046 times.
2056 if(info.isUnwalkable())
14493 {
14494
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 6 times.
10 if(x != x.getInt())
14495 {
14496 4 x.doRound();
14497 4 }
14498
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 else if(hero_newstep_diag > 1)
14499 {
14500
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14501 3 hero_newstep_diag.doFloor();
14502 else --hero_newstep_diag;
14503 3 }
14504 else
14505 3 shiftdir = -1;
14506 10 }
14507 2046 else break;
14508
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 }
14509 10 while(shiftdir != -1);
14510 2049 break;
14511 }
14512 492 else break;
14513
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 359 times.
772 }
14514 772 while(shiftdir != -1);
14515 2900 }
14516
2/2
✓ Branch 0 taken 12170 times.
✓ Branch 1 taken 3000 times.
15170 else if(s==right)
14517 {
14518 3000 do
14519 {
14520 3340 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
14521
14522 3340 execute(info);
14523
14524
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 2685 times.
3340 if(info.isUnwalkable())
14525 {
14526
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 630 times.
655 if(x != x.getInt())
14527 {
14528 25 x.doRound();
14529 25 }
14530
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 315 times.
630 else if(hero_newstep_diag > 1)
14531 {
14532
1/2
✓ Branch 0 taken 315 times.
✗ Branch 1 not taken.
315 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14533 315 hero_newstep_diag.doFloor();
14534 else --hero_newstep_diag;
14535 315 }
14536 else
14537 315 shiftdir = -1;
14538 655 }
14539
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 634 times.
2685 else if(walkable)
14540 {
14541 2051 do
14542 {
14543 2057 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
14544 2057 execute(info);
14545
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2046 times.
2057 if(info.isUnwalkable())
14546 {
14547
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if(x != x.getInt())
14548 {
14549 1 x.doRound();
14550 1 }
14551
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(hero_newstep_diag > 1)
14552 {
14553
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14554 5 hero_newstep_diag.doFloor();
14555 else --hero_newstep_diag;
14556 5 }
14557 else
14558 5 shiftdir = -1;
14559 11 }
14560 2046 else break;
14561
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 5 times.
11 }
14562 11 while(shiftdir != -1);
14563 2051 break;
14564 }
14565 634 else break;
14566
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 315 times.
655 }
14567 655 while(shiftdir != -1);
14568 3000 }
14569 }
14570
14571 18070 move(down);
14572 18070 shiftdir=s;
14573
14574
2/2
✓ Branch 0 taken 15372 times.
✓ Branch 1 taken 2698 times.
18070 if(!walkable)
14575 {
14576
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 1540 times.
2698 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14577 {
14578 1540 x = x.getInt();
14579 1540 y = y.getInt();
14580
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1540 times.
✓ Branch 2 taken 1540 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1026 times.
✓ Branch 5 taken 514 times.
✓ Branch 6 taken 147 times.
✓ Branch 7 taken 1393 times.
2054 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14581
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 514 times.
✓ Branch 2 taken 514 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 440 times.
514 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
14582
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
440 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14583 {
14584
4/8
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 147 times.
147 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
14585 147 sprite::move((zfix)-1,(zfix)0);
14586 147 }
14587
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1393 times.
✓ Branch 2 taken 1393 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 1026 times.
✓ Branch 6 taken 151 times.
✓ Branch 7 taken 1242 times.
2419 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
14588
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1026 times.
✓ Branch 2 taken 1026 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 875 times.
✓ Branch 5 taken 151 times.
1026 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
14589
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 151 times.
151 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
14590 {
14591
4/8
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 151 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 151 times.
151 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
14592 151 sprite::move((zfix)1,(zfix)0);
14593 151 }
14594 else
14595 {
14596 1242 pushing=push+1;
14597 }
14598 1540 }
14599 else
14600 {
14601 1158 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14602 }
14603 2698 }
14604
14605 18070 return;
14606 }
14607 }
14608
14609
6/6
✓ Branch 0 taken 25181 times.
✓ Branch 1 taken 77740 times.
✓ Branch 2 taken 24250 times.
✓ Branch 3 taken 931 times.
✓ Branch 4 taken 24240 times.
✓ Branch 5 taken 10 times.
102921 if(DrunkLeft()&&(holddir==-1||holddir==left))
14610 {
14611
4/8
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 25114 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25171 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14612 {
14613 }
14614 else
14615 {
14616
3/6
✓ Branch 0 taken 25171 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25171 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 25171 times.
25171 if(charging==0 && spins==0 && action != sideswimattacking)
14617 {
14618 25171 dir=left;
14619 25171 }
14620 25171 sideswimdir = left;
14621
14622 25171 holddir=left;
14623
14624
3/4
✓ Branch 0 taken 3488 times.
✓ Branch 1 taken 21683 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3488 times.
25171 if(DrunkUp()&&shiftdir!=down)
14625 {
14626 3488 shiftdir=up;
14627 3488 }
14628
3/4
✓ Branch 0 taken 2746 times.
✓ Branch 1 taken 18937 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2746 times.
21683 else if(DrunkDown()&&shiftdir!=up)
14629 {
14630 2746 shiftdir=down;
14631 2746 }
14632 else
14633 {
14634 18937 shiftdir=-1;
14635 }
14636
14637 25171 do
14638 {
14639 28091 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
14640
14641 28091 info = info || walkflag(x-hero_newstep,y+15,1,left);
14642
14643 28091 execute(info);
14644
14645
2/2
✓ Branch 0 taken 5560 times.
✓ Branch 1 taken 22531 times.
28091 if(info.isUnwalkable())
14646 {
14647
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 5280 times.
5560 if(x != x.getInt())
14648 {
14649 280 x.doRound();
14650 280 }
14651
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 2640 times.
5280 else if(hero_newstep > 1)
14652 {
14653
1/2
✓ Branch 0 taken 2640 times.
✗ Branch 1 not taken.
2640 if(hero_newstep != int32_t(hero_newstep)) //floor
14654 2640 hero_newstep = floor((double)hero_newstep);
14655 else --hero_newstep;
14656 2640 }
14657 else
14658 2640 break;
14659 2920 }
14660 22531 else walkable = true;
14661
2/2
✓ Branch 0 taken 2920 times.
✓ Branch 1 taken 22531 times.
25451 }
14662 25451 while(!walkable);
14663
14664 25171 int32_t s=shiftdir;
14665
14666
10/14
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 25114 times.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1405 times.
✓ Branch 7 taken 23766 times.
✓ Branch 8 taken 1382 times.
✓ Branch 9 taken 23 times.
✓ Branch 10 taken 1382 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1382 times.
✗ Branch 13 not taken.
25171 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14667 {
14668 1382 shiftdir=-1;
14669 1382 }
14670 else
14671 {
14672
2/2
✓ Branch 0 taken 20405 times.
✓ Branch 1 taken 3384 times.
23789 if(s==up)
14673 {
14674 3384 do
14675 {
14676 3928 zfix ty = y - hero_newstep_diag;
14677 7856 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14678 3928 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14679
14680
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3926 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
3928 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14681 {
14682 2 info = info || walkflag(x, zfix(0), 2, up);
14683 2 info = info || walkflag(x+15, zfix(0), 1, up);
14684 2 }
14685 3928 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14686
14687 3928 execute(info);
14688
14689
2/2
✓ Branch 0 taken 1042 times.
✓ Branch 1 taken 2886 times.
3928 if(info.isUnwalkable())
14690 {
14691
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 996 times.
1042 if(y != y.getInt())
14692 {
14693 46 y.doRound();
14694 46 }
14695
2/2
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 498 times.
996 else if(hero_newstep_diag > 1)
14696 {
14697
1/2
✓ Branch 0 taken 498 times.
✗ Branch 1 not taken.
498 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14698 498 hero_newstep_diag.doFloor();
14699 else --hero_newstep_diag;
14700 498 }
14701 else
14702 498 shiftdir = -1;
14703 1042 }
14704
2/2
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 571 times.
2886 else if(walkable)
14705 {
14706 2315 do
14707 {
14708 2337 zfix tx = x-hero_newstep, ty = y-hero_newstep_diag;
14709 2337 info = walkflag(tx,(bigHitbox?0:8)+ty,1,up);
14710
14711
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2335 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2337 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14712 {
14713 2 info = info || walkflag(tx, zfix(0), 1, up);
14714 2 info = info || walkflag(tx+15, zfix(0), 1, up);
14715 2 }
14716 2337 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
14717
14718 2337 execute(info);
14719
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2302 times.
2337 if(info.isUnwalkable())
14720 {
14721
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26 times.
35 if(y != y.getInt())
14722 {
14723 9 y.doRound();
14724 9 }
14725
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 13 times.
26 else if(hero_newstep_diag > 1)
14726 {
14727
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14728 13 hero_newstep_diag.doFloor();
14729 else --hero_newstep_diag;
14730 13 }
14731 else
14732 13 shiftdir = -1;
14733 35 }
14734 2302 else break;
14735
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 13 times.
35 }
14736 35 while(shiftdir != -1);
14737 2315 break;
14738 }
14739 571 else break;
14740
2/2
✓ Branch 0 taken 544 times.
✓ Branch 1 taken 498 times.
1042 }
14741 1042 while(shiftdir != -1);
14742 3384 }
14743
2/2
✓ Branch 0 taken 17720 times.
✓ Branch 1 taken 2685 times.
20405 else if(s==down)
14744 {
14745 2685 do
14746 {
14747 3169 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14748
14749 3169 execute(info);
14750
14751
2/2
✓ Branch 0 taken 917 times.
✓ Branch 1 taken 2252 times.
3169 if(info.isUnwalkable())
14752 {
14753
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 866 times.
917 if(y != y.getInt())
14754 {
14755 51 y.doRound();
14756 51 }
14757
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 433 times.
866 else if(hero_newstep_diag > 1)
14758 {
14759
1/2
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
433 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14760 433 hero_newstep_diag.doFloor();
14761 else --hero_newstep_diag;
14762 433 }
14763 else
14764 433 shiftdir = -1;
14765 917 }
14766
2/2
✓ Branch 0 taken 1849 times.
✓ Branch 1 taken 403 times.
2252 else if(walkable)
14767 {
14768 1849 do
14769 {
14770 1852 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
14771 1852 execute(info);
14772
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1847 times.
1852 if(info.isUnwalkable())
14773 {
14774
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
5 if(y != y.getInt())
14775 {
14776 1 y.doRound();
14777 1 }
14778
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(hero_newstep_diag > 1)
14779 {
14780
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14781 2 hero_newstep_diag.doFloor();
14782 else --hero_newstep_diag;
14783 2 }
14784 else
14785 2 shiftdir = -1;
14786 5 }
14787 1847 else break;
14788
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 }
14789 5 while(shiftdir != -1);
14790 1849 break;
14791 }
14792 403 else break;
14793
2/2
✓ Branch 0 taken 484 times.
✓ Branch 1 taken 433 times.
917 }
14794 917 while(shiftdir != -1);
14795 2685 }
14796 }
14797
14798 25171 move(left);
14799 25171 shiftdir=s;
14800
14801
2/2
✓ Branch 0 taken 22531 times.
✓ Branch 1 taken 2640 times.
25171 if(!walkable)
14802 {
14803
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1594 times.
2640 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
14804 {
14805 1594 x = x.getInt();
14806 1594 y = y.getInt();
14807 1594 int32_t v1=bigHitbox?0:8;
14808 1594 int32_t v2=bigHitbox?8:12;
14809
14810
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1594 times.
✓ Branch 2 taken 1594 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1406 times.
✓ Branch 5 taken 188 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 1553 times.
1782 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
14811
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 188 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
✓ Branch 4 taken 147 times.
✓ Branch 5 taken 41 times.
188 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
14812
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
41 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
14813 {
14814
4/8
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 41 times.
41 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
14815 41 sprite::move((zfix)0,(zfix)-1);
14816 41 }
14817
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1553 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1553 times.
✓ Branch 4 taken 147 times.
✓ Branch 5 taken 1406 times.
✓ Branch 6 taken 41 times.
✓ Branch 7 taken 1512 times.
2959 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
14818
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1406 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1406 times.
✓ Branch 4 taken 1365 times.
✓ Branch 5 taken 41 times.
1406 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
14819
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41 times.
41 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
14820 {
14821
4/8
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 41 times.
41 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
14822 41 sprite::move((zfix)0,(zfix)1);
14823 41 }
14824 else
14825 {
14826 1512 pushing=push+1;
14827 }
14828 1594 }
14829 else
14830 {
14831 1046 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
14832
14833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1046 times.
1046 if(action!=swimming)
14834 {
14835 1046 }
14836 }
14837 2640 }
14838
14839 25171 return;
14840 }
14841 }
14842
14843
5/6
✓ Branch 0 taken 28340 times.
✓ Branch 1 taken 49410 times.
✓ Branch 2 taken 27402 times.
✓ Branch 3 taken 938 times.
✓ Branch 4 taken 27402 times.
✗ Branch 5 not taken.
77750 if(DrunkRight()&&(holddir==-1||holddir==right))
14844 {
14845
4/8
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 28182 times.
✓ Branch 2 taken 158 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 158 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28340 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
14846 {
14847 }
14848 else
14849 {
14850
3/6
✓ Branch 0 taken 28340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28340 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 28340 times.
28340 if(charging==0 && spins==0 && action != sideswimattacking)
14851 {
14852 28340 dir=right;
14853 28340 }
14854 28340 sideswimdir = right;
14855
14856 28340 holddir=right;
14857
14858
3/4
✓ Branch 0 taken 3423 times.
✓ Branch 1 taken 24917 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3423 times.
28340 if(DrunkUp()&&shiftdir!=down)
14859 {
14860 3423 shiftdir=up;
14861 3423 }
14862
4/4
✓ Branch 0 taken 3131 times.
✓ Branch 1 taken 21786 times.
✓ Branch 2 taken 3129 times.
✓ Branch 3 taken 2 times.
24917 else if(DrunkDown()&&shiftdir!=up)
14863 {
14864 3129 shiftdir=down;
14865 3129 }
14866 else
14867 {
14868 21788 shiftdir=-1;
14869 }
14870
14871 28340 do
14872 {
14873 31409 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
14874
14875 31409 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
14876
14877 31409 execute(info);
14878
14879
2/2
✓ Branch 0 taken 5825 times.
✓ Branch 1 taken 25584 times.
31409 if(info.isUnwalkable())
14880 {
14881
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 5606 times.
5825 if(x != x.getInt())
14882 {
14883 219 x.doRound();
14884 219 }
14885
2/2
✓ Branch 0 taken 2850 times.
✓ Branch 1 taken 2756 times.
5606 else if(hero_newstep > 1)
14886 {
14887
1/2
✓ Branch 0 taken 2850 times.
✗ Branch 1 not taken.
2850 if(hero_newstep != int32_t(hero_newstep)) //floor
14888 2850 hero_newstep = floor((double)hero_newstep);
14889 else --hero_newstep;
14890 2850 }
14891 else
14892 2756 break;
14893 3069 }
14894 25584 else walkable = true;
14895
2/2
✓ Branch 0 taken 3069 times.
✓ Branch 1 taken 25584 times.
28653 }
14896 28653 while(!walkable);
14897
14898 28340 int32_t s=shiftdir;
14899
14900
11/14
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 28182 times.
✓ Branch 2 taken 151 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 158 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2440 times.
✓ Branch 7 taken 25900 times.
✓ Branch 8 taken 2422 times.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 2422 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2422 times.
✗ Branch 13 not taken.
28340 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
14901 {
14902 2422 shiftdir=-1;
14903 2422 }
14904 else
14905 {
14906
2/2
✓ Branch 0 taken 22758 times.
✓ Branch 1 taken 3160 times.
25918 if(s==up)
14907 {
14908 3160 do
14909 {
14910 3484 zfix ty = y - hero_newstep_diag;
14911 6968 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
14912 3484 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
14913
14914
3/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 3438 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
3484 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14915 {
14916 46 info = info || walkflag(x, zfix(0), 2, up);
14917 46 info = info || walkflag(x+15, zfix(0), 1, up);
14918 46 }
14919 3484 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
14920
14921 3484 execute(info);
14922
14923
2/2
✓ Branch 0 taken 602 times.
✓ Branch 1 taken 2882 times.
3484 if(info.isUnwalkable())
14924 {
14925
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 556 times.
602 if(y != y.getInt())
14926 {
14927 46 y.doRound();
14928 46 }
14929
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 278 times.
556 else if(hero_newstep_diag > 1)
14930 {
14931
1/2
✓ Branch 0 taken 278 times.
✗ Branch 1 not taken.
278 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14932 278 hero_newstep_diag.doFloor();
14933 else --hero_newstep_diag;
14934 278 }
14935 else
14936 278 shiftdir = -1;
14937 602 }
14938
2/2
✓ Branch 0 taken 2464 times.
✓ Branch 1 taken 418 times.
2882 else if(walkable)
14939 {
14940 2464 do
14941 {
14942 2484 zfix tx = x+hero_newstep, ty = y-hero_newstep_diag;
14943 2484 info = walkflag(tx+15,(bigHitbox?0:8)+ty,1,up);
14944
14945
3/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 2438 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46 times.
2484 if (ty < 0 && !bigHitbox) //sanity check for up scroll
14946 {
14947 46 info = info || walkflag(tx, zfix(0), 1, up);
14948 46 info = info || walkflag(tx+15, zfix(0), 1, up);
14949 46 }
14950 2484 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
14951 2484 execute(info);
14952
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 2453 times.
2484 if(info.isUnwalkable())
14953 {
14954
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 if(y != y.getInt())
14955 {
14956 9 y.doRound();
14957 9 }
14958
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(hero_newstep_diag > 1)
14959 {
14960
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14961 11 hero_newstep_diag.doFloor();
14962 else --hero_newstep_diag;
14963 11 }
14964 else
14965 11 shiftdir = -1;
14966 31 }
14967 2453 else break;
14968
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 11 times.
31 }
14969 31 while(shiftdir != -1);
14970 2464 break;
14971 }
14972 418 else break;
14973
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 278 times.
602 }
14974 602 while(shiftdir != -1);
14975 3160 }
14976
2/2
✓ Branch 0 taken 19776 times.
✓ Branch 1 taken 2982 times.
22758 else if(s==down)
14977 {
14978 2982 do
14979 {
14980 3538 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
14981
14982 3538 execute(info);
14983
14984
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 2492 times.
3538 if(info.isUnwalkable())
14985 {
14986
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 982 times.
1046 if(y != y.getInt())
14987 {
14988 64 y.doRound();
14989 64 }
14990
2/2
✓ Branch 0 taken 492 times.
✓ Branch 1 taken 490 times.
982 else if(hero_newstep_diag > 1)
14991 {
14992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
14993 492 hero_newstep_diag.doFloor();
14994 else --hero_newstep_diag;
14995 492 }
14996 else
14997 490 shiftdir = -1;
14998 1046 }
14999
2/2
✓ Branch 0 taken 2118 times.
✓ Branch 1 taken 374 times.
2492 else if(walkable)
15000 {
15001 2118 do
15002 {
15003 2130 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
15004 2130 execute(info);
15005
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2111 times.
2130 if(info.isUnwalkable())
15006 {
15007
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15 times.
19 if(y != y.getInt())
15008 {
15009 4 y.doRound();
15010 4 }
15011
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 7 times.
15 else if(hero_newstep_diag > 1)
15012 {
15013
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15014 8 hero_newstep_diag.doFloor();
15015 else --hero_newstep_diag;
15016 8 }
15017 else
15018 7 shiftdir = -1;
15019 19 }
15020 2111 else break;
15021
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 }
15022 19 while(shiftdir != -1);
15023 2118 break;
15024 }
15025 374 else break;
15026
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 490 times.
1046 }
15027 1046 while(shiftdir != -1);
15028 2982 }
15029 }
15030
15031 28340 move(right);
15032 28340 shiftdir=s;
15033
15034
2/2
✓ Branch 0 taken 25584 times.
✓ Branch 1 taken 2756 times.
28340 if(!walkable)
15035 {
15036
2/2
✓ Branch 0 taken 847 times.
✓ Branch 1 taken 1909 times.
2756 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15037 {
15038 1909 x = x.getInt();
15039 1909 y = y.getInt();
15040 1909 int32_t v1=bigHitbox?0:8;
15041 1909 int32_t v2=bigHitbox?8:12;
15042
15043
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1909 times.
✓ Branch 2 taken 1909 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1770 times.
✓ Branch 5 taken 139 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1861 times.
2048 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15044
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 91 times.
✓ Branch 5 taken 48 times.
139 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
15045
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
48 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15046 {
15047
4/8
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 48 times.
48 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15048 48 sprite::move((zfix)0,(zfix)-1);
15049 48 }
15050
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1861 times.
✓ Branch 2 taken 1861 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 91 times.
✓ Branch 5 taken 1770 times.
✓ Branch 6 taken 59 times.
✓ Branch 7 taken 1802 times.
3631 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
15051
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1770 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1770 times.
✓ Branch 4 taken 1711 times.
✓ Branch 5 taken 59 times.
1770 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
15052
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
59 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
15053 {
15054
4/8
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 59 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 59 times.
59 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15055 59 sprite::move((zfix)0,(zfix)1);
15056 59 }
15057 else
15058 {
15059 1802 pushing=push+1;
15060 1802 z3step=2;
15061 }
15062 1909 }
15063 else
15064 {
15065 847 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15066
15067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 847 times.
847 if(action!=swimming)
15068 {
15069 847 }
15070 }
15071 2756 }
15072
15073 28340 return;
15074 }
15075 }
15076 49410 }
15077 else
15078 {
15079
6/6
✓ Branch 0 taken 47568 times.
✓ Branch 1 taken 415861 times.
✓ Branch 2 taken 46559 times.
✓ Branch 3 taken 1009 times.
✓ Branch 4 taken 10184 times.
✓ Branch 5 taken 36375 times.
463429 if(DrunkUp()&&(holddir==-1||holddir==up))
15080 {
15081
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 37384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
37384 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15082 {
15083 }
15084 else
15085 {
15086
2/4
✓ Branch 0 taken 37384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37384 times.
37384 if(charging==0 && spins==0)
15087 {
15088 37384 dir=up;
15089 37384 }
15090
15091 37384 holddir=up;
15092
15093
4/4
✓ Branch 0 taken 4714 times.
✓ Branch 1 taken 32670 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 4709 times.
37384 if(DrunkRight()&&shiftdir!=left)
15094 {
15095 4709 shiftdir=right;
15096 4709 }
15097
4/4
✓ Branch 0 taken 3525 times.
✓ Branch 1 taken 29150 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 3520 times.
32675 else if(DrunkLeft()&&shiftdir!=right)
15098 {
15099 3520 shiftdir=left;
15100 3520 }
15101 else
15102 {
15103 29155 shiftdir=-1;
15104 }
15105
15106 //walkable if Ladder can be placed or is already placed vertically
15107
10/18
✓ Branch 0 taken 16485 times.
✓ Branch 1 taken 20899 times.
✓ Branch 2 taken 16485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16354 times.
✓ Branch 5 taken 131 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16354 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 16354 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16354 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16354 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 16354 times.
37384 if(isSideViewHero() && !toogam && !(can_deploy_ladder() || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15108 {
15109 16354 walkable=false;
15110 16354 }
15111 else
15112 {
15113 21030 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15114
15115
2/2
✓ Branch 0 taken 9300 times.
✓ Branch 1 taken 11730 times.
21030 if(x.getInt() & 7)
15116 9300 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15117 else
15118 11730 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15119
15120 21030 execute(info);
15121
15122
2/2
✓ Branch 0 taken 1997 times.
✓ Branch 1 taken 19033 times.
21030 if(info.isUnwalkable())
15123 {
15124
2/2
✓ Branch 0 taken 1945 times.
✓ Branch 1 taken 52 times.
1997 if(z3step==2)
15125 {
15126 1945 z3step=1;
15127 1945 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
15128
15129
2/2
✓ Branch 0 taken 1253 times.
✓ Branch 1 taken 692 times.
1945 if(x.getInt()&7)
15130 692 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
15131 else
15132 1253 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
15133
15134 1945 execute(info);
15135
15136
2/2
✓ Branch 0 taken 1863 times.
✓ Branch 1 taken 82 times.
1945 if(info.isUnwalkable())
15137 {
15138 1863 walkable = false;
15139 1863 }
15140 else
15141 {
15142 82 walkable=true;
15143 }
15144 1945 }
15145 else
15146 {
15147 52 walkable=false;
15148 }
15149 1997 }
15150 else
15151 {
15152 19033 walkable = true;
15153 }
15154 }
15155
15156 37384 int32_t s=shiftdir;
15157
15158
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37384 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15159 {
15160 shiftdir=-1;
15161 }
15162 else
15163 {
15164
2/2
✓ Branch 0 taken 3520 times.
✓ Branch 1 taken 33864 times.
37384 if(s==left)
15165 {
15166 3520 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
15167 3520 execute(info);
15168
15169
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 3064 times.
3520 if(info.isUnwalkable())
15170 {
15171 456 shiftdir=-1;
15172 456 }
15173
2/2
✓ Branch 0 taken 1154 times.
✓ Branch 1 taken 1910 times.
3064 else if(walkable)
15174 {
15175 1910 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
15176 1910 execute(info);
15177
2/2
✓ Branch 0 taken 1907 times.
✓ Branch 1 taken 3 times.
1910 if(info.isUnwalkable())
15178 {
15179 3 shiftdir=-1;
15180 3 }
15181 1910 }
15182 3520 }
15183
2/2
✓ Branch 0 taken 29155 times.
✓ Branch 1 taken 4709 times.
33864 else if(s==right)
15184 {
15185 4709 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15186 4709 execute(info);
15187
15188
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 4005 times.
4709 if(info.isUnwalkable())
15189 {
15190 704 shiftdir=-1;
15191 704 }
15192
2/2
✓ Branch 0 taken 1600 times.
✓ Branch 1 taken 2405 times.
4005 else if(walkable)
15193 {
15194 2405 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
15195 2405 execute(info);
15196
15197
2/2
✓ Branch 0 taken 2403 times.
✓ Branch 1 taken 2 times.
2405 if(info.isUnwalkable())
15198 {
15199 2 shiftdir=-1;
15200 2 }
15201 2405 }
15202 4709 }
15203 }
15204
15205 37384 move(up);
15206 37384 shiftdir=s;
15207
15208
2/2
✓ Branch 0 taken 19115 times.
✓ Branch 1 taken 18269 times.
37384 if(!walkable)
15209 {
15210
2/2
✓ Branch 0 taken 3340 times.
✓ Branch 1 taken 14929 times.
18269 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15211 {
15212
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 14929 times.
✓ Branch 2 taken 14929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1365 times.
✓ Branch 5 taken 13564 times.
✓ Branch 6 taken 117 times.
✓ Branch 7 taken 14812 times.
28493 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15213
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13564 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 13497 times.
13564 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15214
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13497 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13497 times.
13497 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15215 {
15216
5/8
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 109 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 117 times.
117 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15217 117 sprite::move((zfix)-1,(zfix)0);
15218 117 }
15219 else
15220 {
15221
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 14812 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14812 times.
✓ Branch 4 taken 13447 times.
✓ Branch 5 taken 1365 times.
✓ Branch 6 taken 94 times.
✓ Branch 7 taken 14718 times.
16177 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15222
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1365 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
✓ Branch 4 taken 1271 times.
✓ Branch 5 taken 94 times.
1365 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15223
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
94 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15224 {
15225
5/8
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 94 times.
94 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15226 94 sprite::move((zfix)1,(zfix)0);
15227 94 }
15228 else
15229 {
15230 14718 pushing=push+1;
15231 }
15232 }
15233
15234 14929 z3step=2;
15235 14929 }
15236 else
15237 {
15238 3340 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15239 3340 z3step=2;
15240 }
15241 18269 }
15242
15243 37384 return;
15244 }
15245 }
15246
15247
6/6
✓ Branch 0 taken 29624 times.
✓ Branch 1 taken 396421 times.
✓ Branch 2 taken 28877 times.
✓ Branch 3 taken 747 times.
✓ Branch 4 taken 22428 times.
✓ Branch 5 taken 6449 times.
426045 if(DrunkDown()&&(holddir==-1||holddir==down))
15248 {
15249
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 23175 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
23175 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15250 {
15251 }
15252 else
15253 {
15254
2/4
✓ Branch 0 taken 23175 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23175 times.
✗ Branch 3 not taken.
23175 if(charging==0 && spins==0)
15255 {
15256 23175 dir=down;
15257 23175 }
15258
15259 23175 holddir=down;
15260
15261
4/4
✓ Branch 0 taken 3248 times.
✓ Branch 1 taken 19927 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3245 times.
23175 if(DrunkRight()&&shiftdir!=left)
15262 {
15263 3245 shiftdir=right;
15264 3245 }
15265
4/4
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 16906 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3023 times.
19930 else if(DrunkLeft()&&shiftdir!=right)
15266 {
15267 3023 shiftdir=left;
15268 3023 }
15269 else
15270 {
15271 16907 shiftdir=-1;
15272 }
15273
15274 //bool walkable;
15275
7/12
✓ Branch 0 taken 9145 times.
✓ Branch 1 taken 14030 times.
✓ Branch 2 taken 9145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9145 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9145 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 9145 times.
23175 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15276 {
15277 9145 walkable=false;
15278 9145 }
15279 else
15280 {
15281 14030 info = walkflag(x,y+15+z3step,2,down);
15282
15283
2/2
✓ Branch 0 taken 6974 times.
✓ Branch 1 taken 7056 times.
14030 if(x.getInt()&7)
15284 6974 info = info || walkflag(x+16,y+15+z3step,1,down);
15285 else
15286 7056 info = info || walkflagMBlock(x+16, y+15+z3step);
15287
15288 14030 execute(info);
15289
15290
2/2
✓ Branch 0 taken 1246 times.
✓ Branch 1 taken 12784 times.
14030 if(info.isUnwalkable())
15291 {
15292
2/2
✓ Branch 0 taken 1211 times.
✓ Branch 1 taken 35 times.
1246 if(z3step==2)
15293 {
15294 1211 z3step=1;
15295 1211 info = walkflag(x,y+15+z3step,2,down);
15296
15297
2/2
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 594 times.
1211 if(x.getInt()&7)
15298 617 info = info || walkflag(x+16,y+15+z3step,1,down);
15299 else
15300 594 info = info || walkflagMBlock(x+16, y+15+z3step);
15301
15302 1211 execute(info);
15303
15304
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 46 times.
1211 if(info.isUnwalkable())
15305 {
15306 1165 walkable = false;
15307 1165 }
15308 else
15309 {
15310 46 walkable=true;
15311 }
15312 1211 }
15313 else
15314 {
15315 35 walkable=false;
15316 }
15317 1246 }
15318 else
15319 {
15320 12784 walkable = true;
15321 }
15322 }
15323
15324 23175 int32_t s=shiftdir;
15325
15326
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 23175 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23175 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM))
15327 {
15328 shiftdir=-1;
15329 }
15330 else
15331 {
15332
2/2
✓ Branch 0 taken 3023 times.
✓ Branch 1 taken 20152 times.
23175 if(s==left)
15333 {
15334 3023 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
15335 3023 execute(info);
15336
15337
2/2
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 2669 times.
3023 if(info.isUnwalkable())
15338 {
15339 354 shiftdir=-1;
15340 354 }
15341
2/2
✓ Branch 0 taken 1246 times.
✓ Branch 1 taken 1423 times.
2669 else if(walkable)
15342 {
15343 1423 info = walkflag(x-1,y+16,1,left);
15344 1423 execute(info);
15345
15346
2/2
✓ Branch 0 taken 1419 times.
✓ Branch 1 taken 4 times.
1423 if(info.isUnwalkable())
15347 {
15348 4 shiftdir=-1;
15349 4 }
15350 1423 }
15351 3023 }
15352
2/2
✓ Branch 0 taken 16907 times.
✓ Branch 1 taken 3245 times.
20152 else if(s==right)
15353 {
15354 3245 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
15355 3245 execute(info);
15356
15357
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 2888 times.
3245 if(info.isUnwalkable())
15358 {
15359 357 shiftdir=-1;
15360 357 }
15361
2/2
✓ Branch 0 taken 946 times.
✓ Branch 1 taken 1942 times.
2888 else if(walkable)
15362 {
15363 1942 info = walkflag(x+16,y+16,1,right);
15364 1942 execute(info);
15365
15366
2/2
✓ Branch 0 taken 1934 times.
✓ Branch 1 taken 8 times.
1942 if(info.isUnwalkable())
15367 {
15368 8 shiftdir=-1;
15369 8 }
15370 1942 }
15371 3245 }
15372 }
15373
15374 23175 move(down);
15375 23175 shiftdir=s;
15376
15377
2/2
✓ Branch 0 taken 12830 times.
✓ Branch 1 taken 10345 times.
23175 if(!walkable)
15378 {
15379
2/2
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 7917 times.
10345 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15380 {
15381
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7917 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7917 times.
✓ Branch 4 taken 2292 times.
✓ Branch 5 taken 5625 times.
✓ Branch 6 taken 74 times.
✓ Branch 7 taken 7843 times.
13542 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15382
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5625 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5625 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 5465 times.
5625 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
15383
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5465 times.
5465 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15384 {
15385
4/8
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 74 times.
74 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
15386 74 sprite::move((zfix)-1,(zfix)0);
15387 74 }
15388
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7843 times.
✓ Branch 4 taken 5551 times.
✓ Branch 5 taken 2292 times.
✓ Branch 6 taken 93 times.
✓ Branch 7 taken 7750 times.
10135 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
15389
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2292 times.
✓ Branch 4 taken 2199 times.
✓ Branch 5 taken 93 times.
2292 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
15390
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
93 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
15391 {
15392
5/8
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 79 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 93 times.
93 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
15393 93 sprite::move((zfix)1,(zfix)0);
15394 93 }
15395 else //if(shiftdir==-1)
15396 {
15397 7750 pushing=push+1;
15398
15399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7750 times.
7750 if(action!=swimming)
15400 {
15401 7750 }
15402 }
15403
15404 7917 z3step=2;
15405 7917 }
15406 else
15407 {
15408 2428 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15409
15410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2428 times.
2428 if(action!=swimming)
15411 {
15412 2428 }
15413
15414 2428 z3step=2;
15415 }
15416 10345 }
15417
15418 23175 return;
15419 }
15420 }
15421
15422
6/6
✓ Branch 0 taken 104687 times.
✓ Branch 1 taken 298183 times.
✓ Branch 2 taken 101724 times.
✓ Branch 3 taken 2963 times.
✓ Branch 4 taken 101657 times.
✓ Branch 5 taken 67 times.
402870 if(DrunkLeft()&&(holddir==-1||holddir==left))
15423 {
15424
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 104620 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
104620 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15425 {
15426 }
15427 else
15428 {
15429
2/4
✓ Branch 0 taken 104620 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104620 times.
104620 if(charging==0 && spins==0)
15430 {
15431 104620 dir=left;
15432 104620 }
15433
15434 104620 holddir=left;
15435
15436
4/4
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 100237 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4382 times.
104620 if(DrunkUp()&&shiftdir!=down)
15437 {
15438 4382 shiftdir=up;
15439 4382 }
15440
3/4
✓ Branch 0 taken 3124 times.
✓ Branch 1 taken 97114 times.
✓ Branch 2 taken 3124 times.
✗ Branch 3 not taken.
100238 else if(DrunkDown()&&shiftdir!=up)
15441 {
15442 3124 shiftdir=down;
15443 3124 }
15444 else
15445 {
15446 97114 shiftdir=-1;
15447 }
15448
15449 //bool walkable;
15450 104620 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15451
15452
2/2
✓ Branch 0 taken 67603 times.
✓ Branch 1 taken 37017 times.
104620 if(y.getInt()&7)
15453 37017 info = info || walkflag(x-z3step,y+16,1,left);
15454
15455 104620 execute(info);
15456
15457
2/2
✓ Branch 0 taken 12524 times.
✓ Branch 1 taken 92096 times.
104620 if(info.isUnwalkable())
15458 {
15459
2/2
✓ Branch 0 taken 12292 times.
✓ Branch 1 taken 232 times.
12524 if(z3step==2)
15460 {
15461 12292 z3step=1;
15462 12292 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
15463
15464
2/2
✓ Branch 0 taken 4599 times.
✓ Branch 1 taken 7693 times.
12292 if(y.getInt()&7)
15465 4599 info = info || walkflag(x-z3step,y+16,1,left);
15466
15467 12292 execute(info);
15468
15469
2/2
✓ Branch 0 taken 12052 times.
✓ Branch 1 taken 240 times.
12292 if(info.isUnwalkable())
15470 {
15471 12052 walkable = false;
15472 12052 }
15473 else
15474 {
15475 240 walkable=true;
15476 }
15477 12292 }
15478 else
15479 {
15480 232 walkable=false;
15481 }
15482 12524 }
15483 else
15484 {
15485 92096 walkable = true;
15486 }
15487
15488 104620 int32_t s=shiftdir;
15489
15490
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 104620 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56334 times.
✓ Branch 7 taken 48286 times.
✓ Branch 8 taken 56334 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 56334 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 56334 times.
✗ Branch 13 not taken.
104620 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15491 {
15492 56334 shiftdir=-1;
15493 56334 }
15494 else
15495 {
15496
2/2
✓ Branch 0 taken 45195 times.
✓ Branch 1 taken 3091 times.
48286 if(s==up)
15497 {
15498 3091 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15499 3091 execute(info);
15500
15501
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 2831 times.
3091 if(info.isUnwalkable())
15502 {
15503 260 shiftdir=-1;
15504 260 }
15505
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 2677 times.
2831 else if(walkable)
15506 {
15507 2677 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
15508 2677 execute(info);
15509
15510
2/2
✓ Branch 0 taken 2673 times.
✓ Branch 1 taken 4 times.
2677 if(info.isUnwalkable())
15511 {
15512 4 shiftdir=-1;
15513 4 }
15514 2677 }
15515 3091 }
15516
2/2
✓ Branch 0 taken 42632 times.
✓ Branch 1 taken 2563 times.
45195 else if(s==down)
15517 {
15518 2563 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15519 2563 execute(info);
15520
15521
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 2277 times.
2563 if(info.isUnwalkable())
15522 {
15523 286 shiftdir=-1;
15524 286 }
15525
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 2084 times.
2277 else if(walkable)
15526 {
15527 2084 info = walkflag(x-1,y+16,1,down);
15528 2084 execute(info);
15529
15530
2/2
✓ Branch 0 taken 2082 times.
✓ Branch 1 taken 2 times.
2084 if(info.isUnwalkable())
15531 {
15532 2 shiftdir=-1;
15533 2 }
15534 2084 }
15535 2563 }
15536 }
15537
15538 104620 move(left);
15539 104620 shiftdir=s;
15540
15541
2/2
✓ Branch 0 taken 92336 times.
✓ Branch 1 taken 12284 times.
104620 if(!walkable)
15542 {
15543
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 11596 times.
12284 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15544 {
15545 11596 int32_t v1=bigHitbox?0:8;
15546 11596 int32_t v2=bigHitbox?8:12;
15547
15548
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11596 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11596 times.
✓ Branch 4 taken 10373 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 596 times.
✓ Branch 7 taken 11000 times.
12819 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
15549
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1223 times.
✓ Branch 2 taken 1223 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 627 times.
✓ Branch 5 taken 596 times.
1223 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
15550
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 596 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 596 times.
596 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
15551 {
15552
5/8
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 515 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 515 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 596 times.
596 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
15553 596 sprite::move((zfix)0,(zfix)-1);
15554 596 }
15555
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11000 times.
✓ Branch 2 taken 11000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 627 times.
✓ Branch 5 taken 10373 times.
✓ Branch 6 taken 196 times.
✓ Branch 7 taken 10804 times.
21373 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
15556
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10373 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10373 times.
✓ Branch 4 taken 10177 times.
✓ Branch 5 taken 196 times.
10373 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
15557
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 196 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 196 times.
196 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
15558 {
15559
6/8
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 163 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 163 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 195 times.
196 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
15560 195 sprite::move((zfix)0,(zfix)1);
15561 196 }
15562 else //if(shiftdir==-1)
15563 {
15564 10804 pushing=push+1;
15565
15566
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 10795 times.
10804 if(action!=swimming)
15567 {
15568 10795 }
15569 }
15570
15571 11596 z3step=2;
15572 11596 }
15573 else
15574 {
15575 688 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15576
15577
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 682 times.
688 if(action!=swimming)
15578 {
15579 682 }
15580
15581 688 z3step=2;
15582 }
15583 12284 }
15584
15585 104620 return;
15586 }
15587 }
15588
15589
5/6
✓ Branch 0 taken 124134 times.
✓ Branch 1 taken 174116 times.
✓ Branch 2 taken 120783 times.
✓ Branch 3 taken 3351 times.
✓ Branch 4 taken 120783 times.
✗ Branch 5 not taken.
298250 if(DrunkRight()&&(holddir==-1||holddir==right))
15590 {
15591
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
124134 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15592 {
15593 }
15594 else
15595 {
15596
2/4
✓ Branch 0 taken 124134 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 124134 times.
124134 if(charging==0 && spins==0)
15597 {
15598 124134 dir=right;
15599 124134 }
15600
15601 124134 holddir=right;
15602
15603
4/4
✓ Branch 0 taken 5793 times.
✓ Branch 1 taken 118341 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 5792 times.
124134 if(DrunkUp()&&shiftdir!=down)
15604 {
15605 5792 shiftdir=up;
15606 5792 }
15607
3/4
✓ Branch 0 taken 3325 times.
✓ Branch 1 taken 115017 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3325 times.
118342 else if(DrunkDown()&&shiftdir!=up)
15608 {
15609 3325 shiftdir=down;
15610 3325 }
15611 else
15612 {
15613 115017 shiftdir=-1;
15614 }
15615
15616 //bool walkable;
15617 124134 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15618
15619
2/2
✓ Branch 0 taken 80150 times.
✓ Branch 1 taken 43984 times.
124134 if(y.getInt()&7)
15620 43984 info = info || walkflag(x+15+z3step,y+16,1,right);
15621
15622 124134 execute(info);
15623
15624
2/2
✓ Branch 0 taken 13115 times.
✓ Branch 1 taken 111019 times.
124134 if(info.isUnwalkable())
15625 {
15626
2/2
✓ Branch 0 taken 12867 times.
✓ Branch 1 taken 248 times.
13115 if(z3step==2)
15627 {
15628 12867 z3step=1;
15629 12867 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
15630
15631
2/2
✓ Branch 0 taken 5958 times.
✓ Branch 1 taken 6909 times.
12867 if(y.getInt()&7)
15632 5958 info = info || walkflag(x+15+z3step,y+16,1,right);
15633
15634 12867 execute(info);
15635
15636
2/2
✓ Branch 0 taken 12530 times.
✓ Branch 1 taken 337 times.
12867 if(info.isUnwalkable())
15637 {
15638 12530 walkable = false;
15639 12530 }
15640 else
15641 {
15642 337 walkable=true;
15643 }
15644 12867 }
15645 else
15646 {
15647 248 walkable=false;
15648 }
15649 13115 }
15650 else
15651 {
15652 111019 walkable = true;
15653 }
15654
15655 124134 int32_t s=shiftdir;
15656
15657
6/14
✗ Branch 0 not taken.
✓ Branch 1 taken 124134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 65926 times.
✓ Branch 7 taken 58208 times.
✓ Branch 8 taken 65926 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 65926 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 65926 times.
✗ Branch 13 not taken.
124134 if((isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15658 {
15659 65926 shiftdir=-1;
15660 65926 }
15661 else
15662 {
15663
2/2
✓ Branch 0 taken 54178 times.
✓ Branch 1 taken 4030 times.
58208 if(s==up)
15664 {
15665 4030 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
15666 4030 execute(info);
15667
15668
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 3757 times.
4030 if(info.isUnwalkable())
15669 {
15670 273 shiftdir=-1;
15671 273 }
15672
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 3575 times.
3757 else if(walkable)
15673 {
15674 3575 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
15675 3575 execute(info);
15676
15677
2/2
✓ Branch 0 taken 3571 times.
✓ Branch 1 taken 4 times.
3575 if(info.isUnwalkable())
15678 {
15679 4 shiftdir=-1;
15680 4 }
15681 3575 }
15682 4030 }
15683
2/2
✓ Branch 0 taken 51330 times.
✓ Branch 1 taken 2848 times.
54178 else if(s==down)
15684 {
15685 2848 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
15686 2848 execute(info);
15687
15688
2/2
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 2497 times.
2848 if(info.isUnwalkable())
15689 {
15690 351 shiftdir=-1;
15691 351 }
15692
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 2329 times.
2497 else if(walkable)
15693 {
15694 2329 info = walkflag(x+16,y+16,1,down);
15695 2329 execute(info);
15696
15697
2/2
✓ Branch 0 taken 2317 times.
✓ Branch 1 taken 12 times.
2329 if(info.isUnwalkable())
15698 {
15699 12 shiftdir=-1;
15700 12 }
15701 2329 }
15702 2848 }
15703 }
15704
15705 124134 move(right);
15706 124134 shiftdir=s;
15707
15708
2/2
✓ Branch 0 taken 111356 times.
✓ Branch 1 taken 12778 times.
124134 if(!walkable)
15709 {
15710
2/2
✓ Branch 0 taken 877 times.
✓ Branch 1 taken 11901 times.
12778 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15711 {
15712 11901 int32_t v1=bigHitbox?0:8;
15713 11901 int32_t v2=bigHitbox?8:12;
15714
15715 35703 info = !walkflag(x+16,y+v1,1,right)&&
15716 23802 !walkflag(x+16,y+v2,1,right)&&
15717 11901 walkflag(x+16,y+15,1,right);
15718
15719 //do NOT execute these
15720
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 11015 times.
11901 if(info.isUnwalkable())
15721 {
15722
6/8
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 865 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 885 times.
886 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
15723 885 sprite::move((zfix)0,(zfix)-1);
15724 886 }
15725 else
15726 {
15727 33045 info = walkflag(x+16,y+v1, 1,right)&&
15728 22030 !walkflag(x+16,y+v2-1,1,right)&&
15729 11015 !walkflag(x+16,y+15, 1,right);
15730
15731
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 10752 times.
11015 if(info.isUnwalkable())
15732 {
15733
5/8
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 248 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 263 times.
263 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
15734 263 sprite::move((zfix)0,(zfix)1);
15735 263 }
15736 else //if(shiftdir==-1)
15737 {
15738 10752 pushing=push+1;
15739 10752 z3step=2;
15740
15741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10752 times.
10752 if(action!=swimming)
15742 {
15743 10752 }
15744 }
15745 }
15746
15747 11901 z3step=2;
15748 11901 }
15749 else
15750 {
15751 877 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15752
15753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
877 if(action!=swimming)
15754 {
15755 877 }
15756
15757 877 z3step=2;
15758 }
15759 12778 }
15760
15761 124134 return;
15762 }
15763 }
15764 }
15765
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 223526 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
223526 if(shield_forcedir > -1 && action != rafting)
15766 dir = shield_forcedir;
15767 223526 int32_t wtry = iswaterex(MAPCOMBO(x,y+15), currmap, currscr, -1, x,y+15, true, false);
15768 223526 int32_t wtry8 = iswaterex(MAPCOMBO(x+15,y+15), currmap, currscr, -1, x+15,y+15, true, false);
15769 223526 int32_t wtrx = iswaterex(MAPCOMBO(x,y+(bigHitbox?0:8)), currmap, currscr, -1, x,y+(bigHitbox?0:8), true, false);
15770 223526 int32_t wtrx8 = iswaterex(MAPCOMBO(x+15,y+(bigHitbox?0:8)), currmap, currscr, -1, x+15,y+(bigHitbox?0:8), true, false);
15771 223526 int32_t wtrc = iswaterex(MAPCOMBO(x+8,y+(bigHitbox?8:12)), currmap, currscr, -1, x+8,y+(bigHitbox?8:12), true, false);
15772
15773
8/12
✓ Branch 0 taken 47521 times.
✓ Branch 1 taken 176005 times.
✓ Branch 2 taken 47521 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47521 times.
✓ Branch 6 taken 47521 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 44738 times.
✓ Branch 9 taken 2783 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 44738 times.
223526 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))&&!(ladderx+laddery)&&z==0&&fakez==0)
15774 {
15775
7/12
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 44732 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
44738 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
15776 {
15777 //action=swimming;
15778
2/12
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
3 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
15779 {
15780 hopclk = 0xFF;
15781 }
15782 3 }
15783 44738 }
15784
15785 223526 return;
15786 } //endif (LTTPWALK)
15787 1813333 temp_step = hero_newstep;
15788 1813333 temp_x = x;
15789 1813333 temp_y = y;
15790
15791
7/8
✓ Branch 0 taken 1204115 times.
✓ Branch 1 taken 609218 times.
✓ Branch 2 taken 1182645 times.
✓ Branch 3 taken 21470 times.
✓ Branch 4 taken 25964 times.
✓ Branch 5 taken 1178151 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 25964 times.
1813333 if(isdungeon() && (x<=26 || x>=214) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
15792 {
15793
2/4
✓ Branch 0 taken 25964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25964 times.
25964 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15794 goto LEFTRIGHT_NEWMOVE;
15795 25964 else goto LEFTRIGHT_OLDMOVE;
15796 }
15797
15798 // make it easier to get in left & right doors
15799
15800 //ignore ladder for this part. sigh sigh sigh -DD
15801 1787369 oldladderx = ladderx;
15802 1787369 oldladdery = laddery;
15803
2/4
✓ Branch 0 taken 1787369 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1787369 times.
1787369 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15804 {
15805 if(isdungeon() && DrunkLeft() && (temp_x==32 && temp_y==80))
15806 {
15807 do
15808 {
15809 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
15810 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
15811
15812 if(info.isUnwalkable())
15813 {
15814 if(temp_x != int32_t(temp_x))
15815 {
15816 temp_x = floor((double)temp_x);
15817 }
15818 else if(temp_step > 1)
15819 {
15820 if(temp_step != int32_t(temp_step)) //floor
15821 temp_step = floor((double)temp_step);
15822 else --temp_step;
15823 }
15824 else
15825 break;
15826 }
15827 }
15828 while(info.isUnwalkable());
15829
15830 if(!info.isUnwalkable())
15831 {
15832 x = temp_x;
15833 y = temp_y;
15834 hero_newstep = temp_step;
15835 //ONLY process the side-effects of the above walkflag if Hero will actually move
15836 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
15837 execute(info);
15838 move(left);
15839 return;
15840 }
15841 temp_x = x;
15842 temp_y = y;
15843 temp_step = hero_newstep;
15844 }
15845
15846 if(isdungeon() && DrunkRight() && temp_x==208 && temp_y==80)
15847 {
15848 do
15849 {
15850 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
15851 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15852
15853 if(info.isUnwalkable())
15854 {
15855 if(temp_x != int32_t(temp_x))
15856 {
15857 temp_x = floor((double)temp_x);
15858 }
15859 else if(temp_step > 1)
15860 {
15861 if(temp_step != int32_t(temp_step)) //floor
15862 temp_step = floor((double)temp_step);
15863 else --temp_step;
15864 }
15865 else
15866 break;
15867 }
15868 }
15869 while(info.isUnwalkable());
15870
15871 if(!info.isUnwalkable())
15872 {
15873 x = temp_x;
15874 y = temp_y;
15875 hero_newstep = temp_step;
15876 execute(info);
15877 move(right);
15878 return;
15879 }
15880 temp_x = x;
15881 temp_y = y;
15882 temp_step = hero_newstep;
15883 }
15884
15885 ladderx = oldladderx;
15886 laddery = oldladdery;
15887
15888 if(DrunkUp())
15889 {
15890 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
15891 {
15892 if(dir!=up && dir!=down)
15893 {
15894 if(xoff>2&&xoff<6)
15895 {
15896 move(dir);
15897 }
15898 else if(xoff>=6)
15899 {
15900 move(right);
15901 }
15902 else if(xoff>=1)
15903 {
15904 move(left);
15905 }
15906 }
15907 else
15908 {
15909 if(xoff>=4)
15910 {
15911 move(right);
15912 }
15913 else if(xoff<4)
15914 {
15915 move(left);
15916 }
15917 }
15918 }
15919 else
15920 {
15921 do
15922 {
15923 if(action==swimming || IsSideSwim() || action == swimhit)
15924 {
15925 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15926
15927 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,SWITCHBLOCK_STATE) &&
15928 !(iswaterex(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
15929 iswaterex(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), currmap, currscr, -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
15930 info.setUnwalkable(true);
15931 }
15932 else
15933 {
15934 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15935 if(x.getInt() & 7)
15936 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
15937 else
15938 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
15939 }
15940
15941 if(info.isUnwalkable())
15942 {
15943 if(temp_y != int32_t(temp_y))
15944 {
15945 temp_y = floor((double)temp_y);
15946 }
15947 else if(temp_step > 1)
15948 {
15949 if(temp_step != int32_t(temp_step)) //floor
15950 temp_step = floor((double)temp_step);
15951 else --temp_step;
15952 }
15953 else
15954 break;
15955 }
15956 }
15957 while(info.isUnwalkable());
15958
15959 execute(info);
15960
15961 if(!info.isUnwalkable())
15962 {
15963 x = temp_x;
15964 y = temp_y;
15965 hero_newstep = temp_step;
15966 move(up);
15967 return;
15968 }
15969
15970 if(!DrunkLeft() && !DrunkRight())
15971 {
15972 if(NO_GRIDLOCK)
15973 {
15974 x = x.getInt();
15975 y = y.getInt();
15976 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15977 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15978 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15979 {
15980 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
15981 sprite::move((zfix)-1,(zfix)0);
15982 }
15983 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15984 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
15985 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
15986 {
15987 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
15988 sprite::move((zfix)1,(zfix)0);
15989 }
15990 else
15991 {
15992 pushing=push+1;
15993 }
15994 }
15995 else pushing=push+1;
15996
15997 if(charging==0 && spins==0)
15998 {
15999 dir=up;
16000 }
16001
16002 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16003 {
16004 herostep();
16005 }
16006
16007 return;
16008 }
16009 else
16010 {
16011 goto LEFTRIGHT_NEWMOVE;
16012 }
16013 }
16014
16015 return;
16016 }
16017
16018 if(DrunkDown())
16019 {
16020 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16021 {
16022 if(dir!=up && dir!=down)
16023 {
16024 if(xoff>2&&xoff<6)
16025 {
16026 move(dir);
16027 }
16028 else if(xoff>=6)
16029 {
16030 move(right);
16031 }
16032 else if(xoff>=1)
16033 {
16034 move(left);
16035 }
16036 }
16037 else
16038 {
16039 if(xoff>=4)
16040 {
16041 move(right);
16042 }
16043 else if(xoff<4)
16044 {
16045 move(left);
16046 }
16047 }
16048 }
16049 else
16050 {
16051 do
16052 {
16053 if(action==swimming || IsSideSwim() || action == swimhit)
16054 {
16055 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16056
16057 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,SWITCHBLOCK_STATE) &&
16058 !(iswaterex(MAPCOMBO(temp_x, temp_y+15+temp_step), currmap, currscr, -1, temp_x, temp_y+15+temp_step, true, false) &&
16059 iswaterex(MAPCOMBO(temp_x+15, temp_y+15+temp_step), currmap, currscr, -1, temp_x+15, temp_y+15+temp_step, true, false)))
16060 info.setUnwalkable(true);
16061 }
16062 else
16063 {
16064 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
16065 if(x.getInt() & 7)
16066 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
16067 else
16068 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
16069 }
16070
16071 if(info.isUnwalkable())
16072 {
16073 if(temp_y != int32_t(temp_y))
16074 {
16075 temp_y = floor((double)temp_y);
16076 }
16077 else if(temp_step > 1)
16078 {
16079 if(temp_step != int32_t(temp_step)) //floor
16080 temp_step = floor((double)temp_step);
16081 else --temp_step;
16082 }
16083 else
16084 break;
16085 }
16086 }
16087 while(info.isUnwalkable());
16088
16089 execute(info);
16090
16091 if(!info.isUnwalkable())
16092 {
16093 x = temp_x;
16094 y = temp_y;
16095 hero_newstep = temp_step;
16096 move(down);
16097 return;
16098 }
16099
16100 if(!DrunkLeft() && !DrunkRight())
16101 {
16102 if(NO_GRIDLOCK)
16103 {
16104 x = x.getInt();
16105 y = y.getInt();
16106 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16107 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16108 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16109 {
16110 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16111 sprite::move((zfix)-1,(zfix)0);
16112 }
16113 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16114 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16115 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16116 {
16117 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16118 sprite::move((zfix)1,(zfix)0);
16119 }
16120 else
16121 {
16122 pushing=push+1;
16123 }
16124 }
16125 else pushing=push+1;
16126
16127 if(charging==0 && spins==0)
16128 {
16129 dir=down;
16130 }
16131
16132 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16133 {
16134 herostep();
16135 }
16136
16137 return;
16138 }
16139 else goto LEFTRIGHT_NEWMOVE;
16140 }
16141
16142 return;
16143 }
16144
16145 LEFTRIGHT_NEWMOVE:
16146 temp_x = x;
16147 temp_y = y;
16148 temp_step = hero_newstep;
16149 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16150 {
16151 return;
16152 }
16153
16154 if(DrunkLeft())
16155 {
16156 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16157 {
16158 if(dir!=left && dir!=right)
16159 {
16160 if(yoff>2&&yoff<6)
16161 {
16162 move(dir);
16163 }
16164 else if(yoff>=6)
16165 {
16166 move(down);
16167 }
16168 else if(yoff>=1)
16169 {
16170 move(up);
16171 }
16172 }
16173 else
16174 {
16175 if(yoff>=4)
16176 {
16177 move(down);
16178 }
16179 else if(yoff<4)
16180 {
16181 move(up);
16182 }
16183 }
16184 }
16185 else
16186 {
16187 do
16188 {
16189 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
16190 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
16191
16192 if(y.getInt() & 7)
16193 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
16194
16195 if(info.isUnwalkable())
16196 {
16197 if(temp_x != int32_t(temp_x))
16198 {
16199 temp_x = floor((double)temp_x);
16200 }
16201 else if(temp_step > 1)
16202 {
16203 if(temp_step != int32_t(temp_step)) //floor
16204 temp_step = floor((double)temp_step);
16205 else --temp_step;
16206 }
16207 else
16208 break;
16209 }
16210 }
16211 while(info.isUnwalkable());
16212
16213 execute(info);
16214
16215 if(!info.isUnwalkable())
16216 {
16217 x = temp_x;
16218 y = temp_y;
16219 hero_newstep = temp_step;
16220 move(left);
16221 return;
16222 }
16223
16224 if(!DrunkUp() && !DrunkDown())
16225 {
16226 if(NO_GRIDLOCK)
16227 {
16228 x = x.getInt();
16229 y = y.getInt();
16230 int32_t v1=bigHitbox?0:8;
16231 int32_t v2=bigHitbox?8:12;
16232
16233 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16234 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16235 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16236 {
16237 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16238 sprite::move((zfix)0,(zfix)-1);
16239 }
16240 else if(_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16241 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16242 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16243 {
16244 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16245 sprite::move((zfix)0,(zfix)1);
16246 }
16247 else
16248 {
16249 pushing=push+1;
16250 }
16251 }
16252 else pushing=push+1;
16253
16254 if(charging==0 && spins==0)
16255 {
16256 dir=left;
16257 }
16258
16259 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16260 {
16261 herostep();
16262 }
16263
16264 return;
16265 }
16266 }
16267
16268 return;
16269 }
16270
16271 if(DrunkRight())
16272 {
16273 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16274 {
16275 if(dir!=left && dir!=right)
16276 {
16277 if(yoff>2&&yoff<6)
16278 {
16279 move(dir);
16280 }
16281 else if(yoff>=6)
16282 {
16283 move(down);
16284 }
16285 else if(yoff>=1)
16286 {
16287 move(up);
16288 }
16289 }
16290 else
16291 {
16292 if(yoff>=4)
16293 {
16294 move(down);
16295 }
16296 else if(yoff<4)
16297 {
16298 move(up);
16299 }
16300 }
16301 }
16302 else
16303 {
16304 do
16305 {
16306 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
16307 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
16308
16309 if(y.getInt() & 7)
16310 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
16311
16312 if(info.isUnwalkable())
16313 {
16314 if(temp_x != int32_t(temp_x))
16315 {
16316 temp_x = floor((double)temp_x);
16317 }
16318 else if(temp_step > 1)
16319 {
16320 if(temp_step != int32_t(temp_step)) //floor
16321 temp_step = floor((double)temp_step);
16322 else --temp_step;
16323 }
16324 else
16325 break;
16326 }
16327 }
16328 while(info.isUnwalkable());
16329
16330 execute(info);
16331
16332 if(!info.isUnwalkable())
16333 {
16334 x = temp_x;
16335 y = temp_y;
16336 hero_newstep = temp_step;
16337 move(right);
16338 return;
16339 }
16340
16341 if(!DrunkUp() && !DrunkDown())
16342 {
16343 if(NO_GRIDLOCK)
16344 {
16345 x = x.getInt();
16346 y = y.getInt();
16347 int32_t v1=bigHitbox?0:8;
16348 int32_t v2=bigHitbox?8:12;
16349
16350 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16351 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16352 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16353 {
16354 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16355 sprite::move((zfix)0,(zfix)-1);
16356 }
16357 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16358 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16359 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16360 {
16361 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16362 sprite::move((zfix)0,(zfix)1);
16363 }
16364 else
16365 {
16366 pushing=push+1;
16367 }
16368 }
16369 else pushing=push+1;
16370
16371 if(charging==0 && spins==0)
16372 {
16373 dir=right;
16374 }
16375
16376 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16377 {
16378 herostep();
16379 }
16380
16381 return;
16382 }
16383 }
16384 }
16385 }
16386 else
16387 {
16388 3574738 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16389 1787369 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
16390
16391
10/10
✓ Branch 0 taken 1178151 times.
✓ Branch 1 taken 609218 times.
✓ Branch 2 taken 141750 times.
✓ Branch 3 taken 1036401 times.
✓ Branch 4 taken 84983 times.
✓ Branch 5 taken 56767 times.
✓ Branch 6 taken 733 times.
✓ Branch 7 taken 84250 times.
✓ Branch 8 taken 651 times.
✓ Branch 9 taken 82 times.
1787369 if(isdungeon() && DrunkLeft() && !info.isUnwalkable() && (x==32 && y==80))
16392 {
16393 //ONLY process the side-effects of the above walkflag if Hero will actually move
16394 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
16395 651 execute(info);
16396 651 move(left);
16397 651 return;
16398 }
16399
16400 3573436 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
16401 1786718 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
16402
16403
10/10
✓ Branch 0 taken 1177500 times.
✓ Branch 1 taken 609218 times.
✓ Branch 2 taken 156151 times.
✓ Branch 3 taken 1021349 times.
✓ Branch 4 taken 91810 times.
✓ Branch 5 taken 64341 times.
✓ Branch 6 taken 899 times.
✓ Branch 7 taken 90911 times.
✓ Branch 8 taken 87 times.
✓ Branch 9 taken 812 times.
1786718 if(isdungeon() && DrunkRight() && !info.isUnwalkable() && x==208 && y==80)
16404 {
16405 812 execute(info);
16406 812 move(right);
16407 812 return;
16408 }
16409
16410 1785906 ladderx = oldladderx;
16411 1785906 laddery = oldladdery;
16412
16413
2/2
✓ Branch 0 taken 191613 times.
✓ Branch 1 taken 1594293 times.
1785906 if(DrunkUp())
16414 {
16415
11/14
✓ Branch 0 taken 5565 times.
✓ Branch 1 taken 186048 times.
✓ Branch 2 taken 5178 times.
✓ Branch 3 taken 387 times.
✓ Branch 4 taken 4233 times.
✓ Branch 5 taken 945 times.
✓ Branch 6 taken 4233 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4233 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4233 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 4230 times.
191613 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16416 {
16417
3/4
✓ Branch 0 taken 4197 times.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4197 times.
4230 if(dir!=up && dir!=down)
16418 {
16419
4/4
✓ Branch 0 taken 2897 times.
✓ Branch 1 taken 1300 times.
✓ Branch 2 taken 1264 times.
✓ Branch 3 taken 1633 times.
4197 if(xoff>2&&xoff<6)
16420 {
16421 1633 move(dir);
16422 1633 }
16423
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 1300 times.
2564 else if(xoff>=6)
16424 {
16425 1264 move(right);
16426 1264 }
16427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 else if(xoff>=1)
16428 {
16429 1300 move(left);
16430 1300 }
16431 4197 }
16432 else
16433 {
16434
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 if(xoff>=4)
16435 {
16436 10 move(right);
16437 10 }
16438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 else if(xoff<4)
16439 {
16440 23 move(left);
16441 23 }
16442 }
16443 4230 }
16444 else
16445 {
16446
4/6
✓ Branch 0 taken 177048 times.
✓ Branch 1 taken 10335 times.
✓ Branch 2 taken 177048 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 177048 times.
187383 if(action==swimming || IsSideSwim() || action == swimhit)
16447 {
16448 10335 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16449
16450
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10335 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10335 times.
✓ Branch 4 taken 878 times.
✓ Branch 5 taken 9457 times.
✓ Branch 6 taken 7956 times.
✓ Branch 7 taken 2379 times.
19792 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16451
2/2
✓ Branch 0 taken 2376 times.
✓ Branch 1 taken 7081 times.
16538 !(iswaterex(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
16452 7081 iswaterex(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
16453 2379 info.setUnwalkable(true);
16454 10335 }
16455 else
16456 {
16457 177048 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
16458
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 176657 times.
177048 if(x.getInt() & 7)
16459 391 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
16460 else
16461 176657 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
16462 }
16463
16464 187383 execute(info);
16465
16466
2/2
✓ Branch 0 taken 82182 times.
✓ Branch 1 taken 105201 times.
187383 if(!info.isUnwalkable())
16467 {
16468 105201 move(up);
16469 105201 return;
16470 }
16471
16472
4/4
✓ Branch 0 taken 74383 times.
✓ Branch 1 taken 7799 times.
✓ Branch 2 taken 8112 times.
✓ Branch 3 taken 66271 times.
82182 if(!DrunkLeft() && !DrunkRight())
16473 {
16474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66271 times.
66271 if(NO_GRIDLOCK)
16475 {
16476 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16477 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16478 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16479 {
16480 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+(bigHitbox?0:8)-1))
16481 sprite::move((zfix)-1,(zfix)0);
16482 }
16483 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16484 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
16485 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
16486 {
16487 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+(bigHitbox?0:8)-1))
16488 sprite::move((zfix)1,(zfix)0);
16489 }
16490 else
16491 {
16492 pushing=push+1;
16493 }
16494 }
16495 66271 else pushing=push+1;
16496
16497
4/4
✓ Branch 0 taken 66088 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 65992 times.
✓ Branch 3 taken 96 times.
66271 if(charging==0 && spins==0)
16498 {
16499 65992 dir=up;
16500 65992 }
16501
16502
5/8
✓ Branch 0 taken 64499 times.
✓ Branch 1 taken 1772 times.
✓ Branch 2 taken 64499 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64499 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64499 times.
66271 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16503 {
16504 64499 herostep();
16505 64499 }
16506
16507 66271 return;
16508 }
16509 else
16510 {
16511 15911 goto LEFTRIGHT_OLDMOVE;
16512 }
16513 }
16514
16515 4230 return;
16516 }
16517
16518
2/2
✓ Branch 0 taken 165902 times.
✓ Branch 1 taken 1428391 times.
1594293 if(DrunkDown())
16519 {
16520
11/14
✓ Branch 0 taken 5225 times.
✓ Branch 1 taken 160677 times.
✓ Branch 2 taken 4952 times.
✓ Branch 3 taken 273 times.
✓ Branch 4 taken 3316 times.
✓ Branch 5 taken 1636 times.
✓ Branch 6 taken 3316 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3316 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3316 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 3315 times.
165902 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16521 {
16522
3/4
✓ Branch 0 taken 3315 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3314 times.
3315 if(dir!=up && dir!=down)
16523 {
16524
4/4
✓ Branch 0 taken 2360 times.
✓ Branch 1 taken 954 times.
✓ Branch 2 taken 986 times.
✓ Branch 3 taken 1374 times.
3314 if(xoff>2&&xoff<6)
16525 {
16526 1374 move(dir);
16527 1374 }
16528
2/2
✓ Branch 0 taken 986 times.
✓ Branch 1 taken 954 times.
1940 else if(xoff>=6)
16529 {
16530 986 move(right);
16531 986 }
16532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 954 times.
954 else if(xoff>=1)
16533 {
16534 954 move(left);
16535 954 }
16536 3314 }
16537 else
16538 {
16539
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(xoff>=4)
16540 {
16541 1 move(right);
16542 1 }
16543 else if(xoff<4)
16544 {
16545 move(left);
16546 }
16547 }
16548 3315 }
16549 else
16550 {
16551
4/6
✓ Branch 0 taken 151254 times.
✓ Branch 1 taken 11333 times.
✓ Branch 2 taken 151254 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 151254 times.
162587 if(action==swimming || IsSideSwim() || action == swimhit)
16552 {
16553 11333 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16554
16555
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11333 times.
✓ Branch 2 taken 11333 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 729 times.
✓ Branch 5 taken 10604 times.
✓ Branch 6 taken 7395 times.
✓ Branch 7 taken 3938 times.
21937 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,SWITCHBLOCK_STATE) &&
16556
2/2
✓ Branch 0 taken 3885 times.
✓ Branch 1 taken 6719 times.
17323 !(iswaterex(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
16557 6719 iswaterex(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), currmap, currscr, -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
16558 3938 info.setUnwalkable(true);
16559 11333 }
16560 else
16561 {
16562 151254 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
16563
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 150979 times.
151254 if(x.getInt() & 7)
16564 275 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
16565 else
16566 150979 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
16567 }
16568
16569 162587 execute(info);
16570
16571
2/2
✓ Branch 0 taken 76051 times.
✓ Branch 1 taken 86536 times.
162587 if(!info.isUnwalkable())
16572 {
16573 86536 move(down);
16574 86536 return;
16575 }
16576
16577
4/4
✓ Branch 0 taken 67519 times.
✓ Branch 1 taken 8532 times.
✓ Branch 2 taken 7909 times.
✓ Branch 3 taken 59610 times.
76051 if(!DrunkLeft() && !DrunkRight())
16578 {
16579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59610 times.
59610 if(NO_GRIDLOCK)
16580 {
16581 if(!_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16582 !_walkflag(x+8, y+15+1,1,SWITCHBLOCK_STATE)&&
16583 _walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16584 {
16585 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+15,y+15+1))
16586 sprite::move((zfix)-1,(zfix)0);
16587 }
16588 else if(_walkflag(x, y+15+1,1,SWITCHBLOCK_STATE)&&
16589 !_walkflag(x+7, y+15+1,1,SWITCHBLOCK_STATE)&&
16590 !_walkflag(x+15,y+15+1,1,SWITCHBLOCK_STATE))
16591 {
16592 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x,y+15+1))
16593 sprite::move((zfix)1,(zfix)0);
16594 }
16595 else
16596 {
16597 pushing=push+1;
16598 }
16599 }
16600 59610 else pushing=push+1;
16601
16602
2/4
✓ Branch 0 taken 59610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59610 times.
✗ Branch 3 not taken.
59610 if(charging==0 && spins==0)
16603 {
16604 59610 dir=down;
16605 59610 }
16606
16607
5/8
✓ Branch 0 taken 57753 times.
✓ Branch 1 taken 1857 times.
✓ Branch 2 taken 57753 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57753 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57753 times.
59610 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16608 {
16609 57753 herostep();
16610 57753 }
16611
16612 59610 return;
16613 }
16614 16441 else goto LEFTRIGHT_OLDMOVE;
16615 }
16616
16617 3315 return;
16618 }
16619
16620 LEFTRIGHT_OLDMOVE:
16621
16622
7/8
✓ Branch 0 taken 984585 times.
✓ Branch 1 taken 502122 times.
✓ Branch 2 taken 955255 times.
✓ Branch 3 taken 29330 times.
✓ Branch 4 taken 25015 times.
✓ Branch 5 taken 959570 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 25015 times.
1486707 if(isdungeon() && (y<=26 || y>=134) && !get_bit(quest_rules,qr_FREEFORM) && !toogam)
16623 {
16624 25015 return;
16625 }
16626
16627
2/2
✓ Branch 0 taken 215347 times.
✓ Branch 1 taken 1246345 times.
1461692 if(DrunkLeft())
16628 {
16629
11/14
✓ Branch 0 taken 3729 times.
✓ Branch 1 taken 211618 times.
✓ Branch 2 taken 3697 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 3438 times.
✓ Branch 5 taken 259 times.
✓ Branch 6 taken 3438 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3438 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3438 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 3436 times.
215347 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16630 {
16631
3/4
✓ Branch 0 taken 3431 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3431 times.
3436 if(dir!=left && dir!=right)
16632 {
16633
4/4
✓ Branch 0 taken 2444 times.
✓ Branch 1 taken 987 times.
✓ Branch 2 taken 1063 times.
✓ Branch 3 taken 1381 times.
3431 if(yoff>2&&yoff<6)
16634 {
16635 1381 move(dir);
16636 1381 }
16637
2/2
✓ Branch 0 taken 1063 times.
✓ Branch 1 taken 987 times.
2050 else if(yoff>=6)
16638 {
16639 1063 move(down);
16640 1063 }
16641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 987 times.
987 else if(yoff>=1)
16642 {
16643 987 move(up);
16644 987 }
16645 3431 }
16646 else
16647 {
16648
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(yoff>=4)
16649 {
16650 5 move(down);
16651 5 }
16652 else if(yoff<4)
16653 {
16654 move(up);
16655 }
16656 }
16657 3436 }
16658 else
16659 {
16660 423822 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
16661 211911 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
16662
16663 211911 execute(info);
16664
16665
2/2
✓ Branch 0 taken 81481 times.
✓ Branch 1 taken 130430 times.
211911 if(!info.isUnwalkable())
16666 {
16667 130430 move(left);
16668 130430 return;
16669 }
16670
16671
4/4
✓ Branch 0 taken 77721 times.
✓ Branch 1 taken 3760 times.
✓ Branch 2 taken 4590 times.
✓ Branch 3 taken 73131 times.
81481 if(!DrunkUp() && !DrunkDown())
16672 {
16673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73131 times.
73131 if(NO_GRIDLOCK)
16674 {
16675 int32_t v1=bigHitbox?0:8;
16676 int32_t v2=bigHitbox?8:12;
16677
16678 if(!_walkflag(x-1,y+v1,1,SWITCHBLOCK_STATE)&&
16679 !_walkflag(x-1,y+v2,1,SWITCHBLOCK_STATE)&&
16680 _walkflag(x-1,y+15,1,SWITCHBLOCK_STATE))
16681 {
16682 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+15))
16683 sprite::move((zfix)0,(zfix)-1);
16684 }
16685 else if(_walkflag(x-1,y+v1, 1,SWITCHBLOCK_STATE)&&
16686 !_walkflag(x-1,y+v2-1,1,SWITCHBLOCK_STATE)&&
16687 !_walkflag(x-1,y+15, 1,SWITCHBLOCK_STATE))
16688 {
16689 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1))
16690 sprite::move((zfix)0,(zfix)1);
16691 }
16692 else
16693 {
16694 pushing=push+1;
16695 }
16696 }
16697 73131 else pushing=push+1;
16698
16699
3/4
✓ Branch 0 taken 73125 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 73125 times.
73131 if(charging==0 && spins==0)
16700 {
16701 73125 dir=left;
16702 73125 }
16703
16704
5/8
✓ Branch 0 taken 70236 times.
✓ Branch 1 taken 2895 times.
✓ Branch 2 taken 70236 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70236 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70236 times.
73131 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16705 {
16706 70236 herostep();
16707 70236 }
16708
16709 73131 return;
16710 }
16711 }
16712
16713 11786 return;
16714 }
16715
16716
2/2
✓ Branch 0 taken 1016113 times.
✓ Branch 1 taken 230232 times.
1246345 if(DrunkRight())
16717 {
16718
10/14
✓ Branch 0 taken 3715 times.
✓ Branch 1 taken 226517 times.
✓ Branch 2 taken 3607 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 3510 times.
✓ Branch 5 taken 97 times.
✓ Branch 6 taken 3510 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3510 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3510 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 3510 times.
230232 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
16719 {
16720
4/4
✓ Branch 0 taken 3507 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3504 times.
3510 if(dir!=left && dir!=right)
16721 {
16722
4/4
✓ Branch 0 taken 2516 times.
✓ Branch 1 taken 988 times.
✓ Branch 2 taken 1044 times.
✓ Branch 3 taken 1472 times.
3504 if(yoff>2&&yoff<6)
16723 {
16724 1472 move(dir);
16725 1472 }
16726
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 988 times.
2032 else if(yoff>=6)
16727 {
16728 1044 move(down);
16729 1044 }
16730
1/2
✓ Branch 0 taken 988 times.
✗ Branch 1 not taken.
988 else if(yoff>=1)
16731 {
16732 988 move(up);
16733 988 }
16734 3504 }
16735 else
16736 {
16737
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 if(yoff>=4)
16738 {
16739 1 move(down);
16740 1 }
16741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(yoff<4)
16742 {
16743 5 move(up);
16744 5 }
16745 }
16746 3510 }
16747 else
16748 {
16749 453444 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
16750 226722 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
16751
16752 226722 execute(info);
16753
16754
2/2
✓ Branch 0 taken 85313 times.
✓ Branch 1 taken 141409 times.
226722 if(!info.isUnwalkable())
16755 {
16756 141409 move(right);
16757 141409 return;
16758 }
16759
16760
4/4
✓ Branch 0 taken 82019 times.
✓ Branch 1 taken 3294 times.
✓ Branch 2 taken 3243 times.
✓ Branch 3 taken 78776 times.
85313 if(!DrunkUp() && !DrunkDown())
16761 {
16762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78776 times.
78776 if(NO_GRIDLOCK)
16763 {
16764 int32_t v1=bigHitbox?0:8;
16765 int32_t v2=bigHitbox?8:12;
16766
16767 if(!_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16768 !_walkflag(x+16,y+v2,1,SWITCHBLOCK_STATE)&&
16769 _walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16770 {
16771 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+15))
16772 sprite::move((zfix)0,(zfix)-1);
16773 }
16774 else if(_walkflag(x+16,y+v1,1,SWITCHBLOCK_STATE)&&
16775 !_walkflag(x+16,y+v2-1,1,SWITCHBLOCK_STATE)&&
16776 !_walkflag(x+16,y+15,1,SWITCHBLOCK_STATE))
16777 {
16778 if(hclk || ((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1))
16779 sprite::move((zfix)0,(zfix)1);
16780 }
16781 else
16782 {
16783 pushing=push+1;
16784 }
16785 }
16786 78776 else pushing=push+1;
16787
16788
2/4
✓ Branch 0 taken 78776 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78776 times.
78776 if(charging==0 && spins==0)
16789 {
16790 78776 dir=right;
16791 78776 }
16792
16793
5/8
✓ Branch 0 taken 78206 times.
✓ Branch 1 taken 570 times.
✓ Branch 2 taken 78206 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78206 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 78206 times.
78776 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16794 {
16795 78206 herostep();
16796 78206 }
16797
16798 78776 return;
16799 }
16800 }
16801 10047 }
16802 }
16803 4992709 }
16804
16805 //solid ffc checking should probably be moved to here.
16806 2793195 void HeroClass::move(int32_t d2, int32_t forceRate)
16807 {
16808
4/6
✓ Branch 0 taken 2792917 times.
✓ Branch 1 taken 278 times.
✓ Branch 2 taken 2792917 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2792917 times.
2793195 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
16809 278 return;
16810
16811
3/4
✓ Branch 0 taken 2703760 times.
✓ Branch 1 taken 89157 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2703760 times.
2792917 if(!get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
16812 {
16813 2703760 moveOld(d2);
16814 2703760 return;
16815 }
16816
16817
4/8
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 86181 times.
✓ Branch 2 taken 2976 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2976 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
175338 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || tmpscr->flags2&fAIRCOMBOS)) ||
16818
5/6
✓ Branch 0 taken 4699 times.
✓ Branch 1 taken 81482 times.
✓ Branch 2 taken 1836 times.
✓ Branch 3 taken 2863 times.
✓ Branch 4 taken 4699 times.
✗ Branch 5 not taken.
86181 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
16819 //!DIMITODO: add QR for slow combos under hero
16820
2/2
✓ Branch 0 taken 178314 times.
✓ Branch 1 taken 89157 times.
267471 for (int32_t i = 0; i <= 1; ++i)
16821 {
16822
2/2
✓ Branch 0 taken 50503 times.
✓ Branch 1 taken 127811 times.
178314 if(tmpscr2[i].valid!=0)
16823 {
16824
2/2
✓ Branch 0 taken 16800 times.
✓ Branch 1 taken 111011 times.
127811 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
16825 {
16826
2/4
✓ Branch 0 taken 111011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111011 times.
✗ Branch 3 not taken.
111011 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16827 111011 }
16828 else
16829 {
16830
4/4
✓ Branch 0 taken 16716 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 16716 times.
✓ Branch 3 taken 84 times.
16800 if (combobuf[MAPCOMBO2(i,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8,1, &(tmpscr2[i]))) slowcombo = false;
16831 }
16832 127811 }
16833 178314 }
16834
1/2
✓ Branch 0 taken 89157 times.
✗ Branch 1 not taken.
89157 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
16835 89157 bool is_swimming = (action == swimming);
16836 89157 bool fastSwim = (zinit.hero_swim_speed>60);
16837 89157 zfix rate(steprate);
16838 89157 int32_t shieldid = getCurrentActiveShield();
16839
1/2
✓ Branch 0 taken 89157 times.
✗ Branch 1 not taken.
89157 if(shieldid > -1)
16840 {
16841 itemdata const& shield = itemsbuf[shieldid];
16842 if(shield.flags & ITEM_FLAG10) //Change Speed flag
16843 {
16844 zfix perc = shield.misc7;
16845 perc /= 100;
16846 if(perc < 0)
16847 perc = (perc*-1)+1;
16848 rate = (rate * perc) + shield.misc8;
16849 }
16850 }
16851
16852 89157 zfix dx, dy;
16853 89157 zfix movepix(rate / 100);
16854 89157 zfix step(movepix);
16855 89157 zfix step_diag(movepix);
16856 89157 zfix up_step(game->get_sideswim_up() / -100.0);
16857 89157 zfix left_step(game->get_sideswim_side() / -100.0);
16858 89157 zfix right_step(game->get_sideswim_side() / 100.0);
16859 89157 zfix down_step(game->get_sideswim_down() / 100.0);
16860 89157 bool checkladder = false;
16861
16862
2/2
✓ Branch 0 taken 89156 times.
✓ Branch 1 taken 1 times.
89157 if(hero_newstep > movepix) hero_newstep = movepix;
16863
2/2
✓ Branch 0 taken 89156 times.
✓ Branch 1 taken 1 times.
89157 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
16864 //2/3 speed
16865
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 89157 times.
✓ Branch 2 taken 86181 times.
✓ Branch 3 taken 86181 times.
✓ Branch 4 taken 89157 times.
✓ Branch 5 taken 86181 times.
89157 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
16866 {
16867 175338 step = ((step / 3.0) * 2);
16868 175338 step_diag = ((step_diag / 3.0) * 2);
16869 175338 up_step = ((up_step / 3.0) * 2);
16870 175338 left_step = ((left_step / 3.0) * 2);
16871 175338 right_step = ((right_step / 3.0) * 2);
16872 175338 down_step = ((down_step / 3.0) * 2);
16873 175338 }
16874 //1/2 speed
16875
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 86181 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 86181 times.
86181 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
16876 {
16877 step /= 2;
16878 step_diag /= 2;
16879 up_step /= 2;
16880 left_step /= 2;
16881 right_step /= 2;
16882 down_step /= 2;
16883 }
16884 //normal speed
16885 else
16886 {
16887 //no modification
16888 }
16889
16890
1/2
✓ Branch 0 taken 89157 times.
✗ Branch 1 not taken.
89157 if(diagonalMovement)
16891 {
16892 //zprint2("Player's X is %d, Y is %d\n", x, y);
16893
6/6
✓ Branch 0 taken 71593 times.
✓ Branch 1 taken 17564 times.
✓ Branch 2 taken 73269 times.
✓ Branch 3 taken 4310 times.
✓ Branch 4 taken 31256 times.
✓ Branch 5 taken 59577 times.
136936 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
16894
4/4
✓ Branch 0 taken 55007 times.
✓ Branch 1 taken 50697 times.
✓ Branch 2 taken 5324 times.
✓ Branch 3 taken 49683 times.
4310 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
16895 {
16896
2/4
✓ Branch 0 taken 19458 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19458 times.
138612 if(hero_newstep > 0 && hero_newstep_diag > 0)
16897 {
16898 19458 step = STEP_DIAGONAL(step);
16899 19458 step_diag = STEP_DIAGONAL(step_diag);
16900 19458 up_step = STEP_DIAGONAL(up_step);
16901 19458 left_step = STEP_DIAGONAL(left_step);
16902 19458 right_step = STEP_DIAGONAL(right_step);
16903 19458 down_step = STEP_DIAGONAL(down_step);
16904 19458 }
16905 19458 }
16906
2/2
✓ Branch 0 taken 61647 times.
✓ Branch 1 taken 7494 times.
69141 if(hero_newstep < step) step = hero_newstep; //handle collision
16907
2/2
✓ Branch 0 taken 66257 times.
✓ Branch 1 taken 2884 times.
69141 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
16908
5/5
✓ Branch 0 taken 20016 times.
✓ Branch 1 taken 17564 times.
✓ Branch 2 taken 18070 times.
✓ Branch 3 taken 25171 times.
✓ Branch 4 taken 28352 times.
69141 switch(d2)
16909 {
16910 case up:
16911
3/3
✓ Branch 0 taken 13803 times.
✓ Branch 1 taken 1840 times.
✓ Branch 2 taken 1921 times.
17564 switch(shiftdir)
16912 {
16913 case left:
16914 1840 dx = -step_diag;
16915
1/2
✓ Branch 0 taken 1840 times.
✗ Branch 1 not taken.
1840 if (IsSideSwim()) dx = left_step;
16916 1840 break;
16917 case right:
16918 1921 dx = step_diag;
16919
1/2
✓ Branch 0 taken 1921 times.
✗ Branch 1 not taken.
1921 if (IsSideSwim()) dx = right_step;
16920 1921 break;
16921 }
16922
2/2
✓ Branch 0 taken 2580 times.
✓ Branch 1 taken 14984 times.
17564 if(walkable)
16923 {
16924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14984 times.
14984 if (!IsSideSwim()) dy = -step;
16925
1/2
✓ Branch 0 taken 14984 times.
✗ Branch 1 not taken.
14984 if (IsSideSwim())
16926 {
16927 dy = up_step;
16928 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16929 }
16930 14984 }
16931 17564 break;
16932 case down:
16933
3/3
✓ Branch 0 taken 12852 times.
✓ Branch 1 taken 2538 times.
✓ Branch 2 taken 2680 times.
18070 switch(shiftdir)
16934 {
16935 case left:
16936 2538 dx = -step_diag;
16937
1/2
✓ Branch 0 taken 2538 times.
✗ Branch 1 not taken.
2538 if (IsSideSwim()) dx = left_step;
16938 2538 break;
16939 case right:
16940 2680 dx = step_diag;
16941
1/2
✓ Branch 0 taken 2680 times.
✗ Branch 1 not taken.
2680 if (IsSideSwim()) dx = right_step;
16942 2680 break;
16943 }
16944
2/2
✓ Branch 0 taken 2698 times.
✓ Branch 1 taken 15372 times.
18070 if(walkable)
16945 {
16946 15372 dy = step;
16947
1/2
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
15372 if (IsSideSwim()) dy = down_step;
16948 15372 }
16949 18070 break;
16950 case left:
16951
3/3
✓ Branch 0 taken 20048 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 2250 times.
25171 switch(shiftdir)
16952 {
16953 case up:
16954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2873 times.
2873 if (!IsSideSwim()) dy = -step_diag;
16955
1/2
✓ Branch 0 taken 2873 times.
✗ Branch 1 not taken.
2873 if (IsSideSwim())
16956 {
16957 dy = up_step;
16958 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16959 }
16960 2873 break;
16961 case down:
16962 2250 dy = step_diag;
16963
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if (IsSideSwim()) dy = down_step;
16964 2250 break;
16965 }
16966
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 22531 times.
25171 if(walkable)
16967 {
16968 22531 dx = -step;
16969
1/2
✓ Branch 0 taken 22531 times.
✗ Branch 1 not taken.
22531 if (IsSideSwim()) dx = left_step;
16970 22531 }
16971 25171 break;
16972 case right:
16973
3/3
✓ Branch 0 taken 22996 times.
✓ Branch 1 taken 2871 times.
✓ Branch 2 taken 2485 times.
28352 switch(shiftdir)
16974 {
16975 case up:
16976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2871 times.
2871 if (!IsSideSwim()) dy = -step_diag;
16977
1/2
✓ Branch 0 taken 2871 times.
✗ Branch 1 not taken.
2871 if (IsSideSwim())
16978 {
16979 dy = up_step;
16980 if (!iswaterex(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), currmap, currscr, -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
16981 }
16982 2871 break;
16983 case down:
16984 2485 dy = step_diag;
16985
1/2
✓ Branch 0 taken 2485 times.
✗ Branch 1 not taken.
2485 if (IsSideSwim()) dy = down_step;
16986 2485 break;
16987 }
16988
2/2
✓ Branch 0 taken 2756 times.
✓ Branch 1 taken 25596 times.
28352 if(walkable)
16989 {
16990 25596 dx = step;
16991
1/2
✓ Branch 0 taken 25596 times.
✗ Branch 1 not taken.
25596 if (IsSideSwim()) dx = right_step;
16992 25596 }
16993 28352 break;
16994 };
16995 109173 }
16996 else
16997 {
16998 if(hero_newstep < step) step = hero_newstep; //handle collision
16999 switch(d2)
17000 {
17001 case up:
17002 dy -= step;
17003 if (IsSideSwim()) dy = up_step;
17004 break;
17005 case down:
17006 dy += step;
17007 if (IsSideSwim()) dy = down_step;
17008 break;
17009 case left:
17010 dx -= step;
17011 if (IsSideSwim()) dx = left_step;
17012 break;
17013 case right:
17014 dx += step;
17015 if (IsSideSwim()) dx = right_step;
17016 break;
17017 };
17018 }
17019 109173 hero_newstep = movepix;
17020 109173 hero_newstep_diag = movepix;
17021
17022
6/16
✗ Branch 0 not taken.
✓ Branch 1 taken 109173 times.
✓ Branch 2 taken 89157 times.
✓ Branch 3 taken 20016 times.
✓ Branch 4 taken 89157 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89157 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 89157 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
109173 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
17023 {
17024 89157 dir=d2;
17025 89157 }
17026
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 20016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
20016 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
17027 {
17028 dir = shiftdir;
17029 }
17030
2/2
✓ Branch 0 taken 109161 times.
✓ Branch 1 taken 12 times.
109173 if(forceRate > -1)
17031 {
17032 12 checkladder = false;
17033
1/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
12 switch(dir)
17034 {
17035 case right:
17036 case r_up:
17037 case r_down:
17038 12 dx = zfix(forceRate) / 100;
17039 12 break;
17040 case left:
17041 case l_up:
17042 case l_down:
17043 dx = zfix(-forceRate) / 100;
17044 break;
17045 default:
17046 dx = 0;
17047 }
17048
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
12 switch(dir)
17049 {
17050 case down:
17051 case r_down:
17052 case l_down:
17053 dy = zfix(forceRate) / 100;
17054 break;
17055 case up:
17056 case r_up:
17057 case l_up:
17058 dy = zfix(-forceRate) / 100;
17059 break;
17060 default:
17061 12 dy = 0;
17062 12 }
17063 12 }
17064
4/4
✓ Branch 0 taken 32051 times.
✓ Branch 1 taken 77122 times.
✓ Branch 2 taken 24872 times.
✓ Branch 3 taken 7179 times.
109173 if(dx == 0 && dy == 0) return;
17065
5/8
✓ Branch 0 taken 81978 times.
✓ Branch 1 taken 20016 times.
✓ Branch 2 taken 81978 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 81978 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 81978 times.
101994 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17066 {
17067 81978 herostep();
17068
17069 //ack... don't walk if in midair! -DD
17070
10/14
✓ Branch 0 taken 81978 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 81978 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 81978 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 81978 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4274 times.
✓ Branch 9 taken 77704 times.
✓ Branch 10 taken 1621 times.
✓ Branch 11 taken 2653 times.
✓ Branch 12 taken 179 times.
✓ Branch 13 taken 1442 times.
81978 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
17071 {
17072 80536 action=walking; FFCore.setHeroAction(walking);
17073 80536 }
17074
17075
2/2
✓ Branch 0 taken 77784 times.
✓ Branch 1 taken 4194 times.
81978 if(++hero_count > (16*hero_animation_speed))
17076 4194 hero_count=0;
17077 81978 }
17078
1/2
✓ Branch 0 taken 20016 times.
✗ Branch 1 not taken.
20016 else if(!(frame & 1))
17079 {
17080 herostep();
17081 }
17082
17083
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 101994 times.
✓ Branch 2 taken 20016 times.
✓ Branch 3 taken 20016 times.
101994 if(charging==0 || attack!=wHammer)
17084 {
17085 122010 sprite::move(dx, dy);
17086 122010 WalkflagInfo info;
17087 122010 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
17088 122010 execute(info);
17089
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 81978 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 81978 times.
✗ Branch 7 not taken.
122010 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
17090 {
17091 if (game->get_sideswim_jump() != 0)
17092 {
17093 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
17094 sfx(WAV_ZN1SPLASH,(int32_t)x);
17095 hopclk = 0;
17096 if (charging || spins) action = attacking;
17097 else action = none;
17098 }
17099 else
17100 {
17101 sprite::move(zfix(0), zfix(-1*dy));
17102 }
17103 }
17104 81978 }
17105 2813211 }
17106
17107 2703760 void HeroClass::moveOld(int32_t d2)
17108 {
17109 //al_trace("%s\n",d2==up?"up":d2==down?"down":d2==left?"left":d2==right?"right":"?");
17110 static bool totalskip = false;
17111
17112
3/6
✓ Branch 0 taken 2703760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2703760 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2703760 times.
2703760 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
17113 return;
17114
17115 2703760 int32_t dx=0,dy=0;
17116 2703760 int32_t xstep=lsteps[x.getInt()&7];
17117 2703760 int32_t ystep=lsteps[y.getInt()&7];
17118 2703760 int32_t z3skip=0;
17119 2703760 int32_t z3diagskip=0;
17120
3/6
✓ Branch 0 taken 57608 times.
✓ Branch 1 taken 2646152 times.
✓ Branch 2 taken 57608 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5349912 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || tmpscr->flags2&fAIRCOMBOS)) ||
17121
5/6
✓ Branch 0 taken 149353 times.
✓ Branch 1 taken 2496799 times.
✓ Branch 2 taken 81755 times.
✓ Branch 3 taken 67598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 81755 times.
2646152 (isSideViewHero() && (on_sideview_solid_oldpos(x,y,old_x,old_y)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
17122
2/2
✓ Branch 0 taken 2703174 times.
✓ Branch 1 taken 586 times.
2703760 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & ITEM_FLAG10);
17123 2703760 bool is_swimming = (action == swimming);
17124
17125 //slow walk combo, or charging, moves at 2/3 speed
17126 if(
17127
4/4
✓ Branch 0 taken 2663126 times.
✓ Branch 1 taken 40634 times.
✓ Branch 2 taken 57971 times.
✓ Branch 3 taken 2605155 times.
2744394 (!is_swimming && (slowcharging ^ slowcombo))||
17128
2/2
✓ Branch 0 taken 40634 times.
✓ Branch 1 taken 2605155 times.
2645789 (is_swimming && (zinit.hero_swim_speed>60))
17129 )
17130 {
17131 98605 totalskip = false;
17132
17133
2/2
✓ Branch 0 taken 4647 times.
✓ Branch 1 taken 93958 times.
98605 if(diagonalMovement)
17134 {
17135 4647 skipstep=(skipstep+1)%6;
17136
17137
2/2
✓ Branch 0 taken 2359 times.
✓ Branch 1 taken 2288 times.
4647 if(skipstep%2==0) z3skip=1;
17138 2359 else z3skip=0;
17139
17140
2/2
✓ Branch 0 taken 3136 times.
✓ Branch 1 taken 1511 times.
4647 if(skipstep%3==0) z3diagskip=1;
17141 3136 else z3diagskip=0;
17142 4647 }
17143 else
17144 {
17145
2/2
✓ Branch 0 taken 59422 times.
✓ Branch 1 taken 34536 times.
93958 if(d2<left)
17146 {
17147
2/2
✓ Branch 0 taken 35924 times.
✓ Branch 1 taken 23498 times.
59422 if(ystep>1)
17148 {
17149 23498 skipstep^=1;
17150 23498 ystep=skipstep;
17151 23498 }
17152 59422 }
17153 else
17154 {
17155
2/2
✓ Branch 0 taken 21017 times.
✓ Branch 1 taken 13519 times.
34536 if(xstep>1)
17156 {
17157 13519 skipstep^=1;
17158 13519 xstep=skipstep;
17159 13519 }
17160 }
17161 }
17162 98605 }
17163 // else if(is_swimming || (slowcharging && slowcombo))
17164 else if(
17165
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2605155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2605266 (is_swimming && (zinit.hero_swim_speed<60))||
17166
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 2605044 times.
2605155 (slowcharging && slowcombo)
17167 )
17168 {
17169 //swimming, or charging on a slow combo, moves at 1/2 speed
17170 111 totalskip = !totalskip;
17171
17172
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
17173 {
17174 skipstep=0;
17175 }
17176 111 }
17177 else
17178 {
17179 2605044 totalskip = false;
17180
17181
2/2
✓ Branch 0 taken 2320378 times.
✓ Branch 1 taken 284666 times.
2605044 if(diagonalMovement)
17182 {
17183 284666 skipstep=0;
17184 284666 }
17185 }
17186
17187
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 2703704 times.
2703760 if(!totalskip)
17188 {
17189
2/2
✓ Branch 0 taken 289313 times.
✓ Branch 1 taken 2414391 times.
2703704 if(diagonalMovement)
17190 {
17191
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 37384 times.
✓ Branch 2 taken 23175 times.
✓ Branch 3 taken 124134 times.
✓ Branch 4 taken 104620 times.
289313 switch(d2)
17192 {
17193 case up:
17194
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 34323 times.
37384 if(shiftdir==left)
17195 {
17196
2/2
✓ Branch 0 taken 1907 times.
✓ Branch 1 taken 1154 times.
3061 if(walkable)
17197 {
17198 1907 dy-=1-z3diagskip;
17199 1907 dx-=1-z3diagskip;
17200 1907 z3step=2;
17201 1907 }
17202 else
17203 {
17204 1154 dx-=1-z3diagskip;
17205 1154 z3step=2;
17206 }
17207 3061 }
17208
2/2
✓ Branch 0 taken 4003 times.
✓ Branch 1 taken 30320 times.
34323 else if(shiftdir==right)
17209 {
17210
2/2
✓ Branch 0 taken 2403 times.
✓ Branch 1 taken 1600 times.
4003 if(walkable)
17211 {
17212 2403 dy-=1-z3diagskip;
17213 2403 dx+=1-z3diagskip;
17214 2403 z3step=2;
17215 2403 }
17216 else
17217 {
17218 1600 dx+=1-z3diagskip;
17219 1600 z3step=2;
17220 }
17221 4003 }
17222 else
17223 {
17224
2/2
✓ Branch 0 taken 15515 times.
✓ Branch 1 taken 14805 times.
30320 if(walkable)
17225 {
17226 14805 dy-=z3step-z3skip;
17227 14805 z3step=(z3step%2)+1;
17228 14805 }
17229 }
17230
17231 37384 break;
17232
17233 case down:
17234
2/2
✓ Branch 0 taken 2665 times.
✓ Branch 1 taken 20510 times.
23175 if(shiftdir==left)
17235 {
17236
2/2
✓ Branch 0 taken 1419 times.
✓ Branch 1 taken 1246 times.
2665 if(walkable)
17237 {
17238 1419 dy+=1-z3diagskip;
17239 1419 dx-=1-z3diagskip;
17240 1419 z3step=2;
17241 1419 }
17242 else
17243 {
17244 1246 dx-=1-z3diagskip;
17245 1246 z3step=2;
17246 }
17247 2665 }
17248
2/2
✓ Branch 0 taken 2880 times.
✓ Branch 1 taken 17630 times.
20510 else if(shiftdir==right)
17249 {
17250
2/2
✓ Branch 0 taken 1934 times.
✓ Branch 1 taken 946 times.
2880 if(walkable)
17251 {
17252 1934 dy+=1-z3diagskip;
17253 1934 dx+=1-z3diagskip;
17254 1934 z3step=2;
17255 1934 }
17256 else
17257 {
17258 946 dx+=1-z3diagskip;
17259 946 z3step=2;
17260 }
17261 2880 }
17262 else
17263 {
17264
2/2
✓ Branch 0 taken 8153 times.
✓ Branch 1 taken 9477 times.
17630 if(walkable)
17265 {
17266 9477 dy+=z3step-z3skip;
17267 9477 z3step=(z3step%2)+1;
17268 9477 }
17269 }
17270
17271 23175 break;
17272
17273 case right:
17274
2/2
✓ Branch 0 taken 120381 times.
✓ Branch 1 taken 3753 times.
124134 if(shiftdir==up)
17275 {
17276
2/2
✓ Branch 0 taken 3571 times.
✓ Branch 1 taken 182 times.
3753 if(walkable)
17277 {
17278 3571 dy-=1-z3diagskip;
17279 3571 dx+=1-z3diagskip;
17280 3571 z3step=2;
17281 3571 }
17282 else
17283 {
17284 182 dy-=1-z3diagskip;
17285 182 z3step=2;
17286 }
17287 3753 }
17288
2/2
✓ Branch 0 taken 2485 times.
✓ Branch 1 taken 117896 times.
120381 else if(shiftdir==down)
17289 {
17290
2/2
✓ Branch 0 taken 2317 times.
✓ Branch 1 taken 168 times.
2485 if(walkable)
17291 {
17292 2317 dy+=1-z3diagskip;
17293 2317 dx+=1-z3diagskip;
17294 2317 z3step=2;
17295 2317 }
17296 else
17297 {
17298 168 dy+=1-z3diagskip;
17299 168 z3step=2;
17300 }
17301 2485 }
17302 else
17303 {
17304
2/2
✓ Branch 0 taken 12428 times.
✓ Branch 1 taken 105468 times.
117896 if(walkable)
17305 {
17306 105468 dx+=z3step-z3skip;
17307 105468 z3step=(z3step%2)+1;
17308 105468 }
17309 }
17310
17311 124134 break;
17312
17313 case left:
17314
2/2
✓ Branch 0 taken 101793 times.
✓ Branch 1 taken 2827 times.
104620 if(shiftdir==up)
17315 {
17316
2/2
✓ Branch 0 taken 2673 times.
✓ Branch 1 taken 154 times.
2827 if(walkable)
17317 {
17318 2673 dy-=1-z3diagskip;
17319 2673 dx-=1-z3diagskip;
17320 2673 z3step=2;
17321 2673 }
17322 else
17323 {
17324 154 dy-=1-z3diagskip;
17325 154 z3step=2;
17326 }
17327 2827 }
17328
2/2
✓ Branch 0 taken 2275 times.
✓ Branch 1 taken 99518 times.
101793 else if(shiftdir==down)
17329 {
17330
2/2
✓ Branch 0 taken 2082 times.
✓ Branch 1 taken 193 times.
2275 if(walkable)
17331 {
17332 2082 dy+=1-z3diagskip;
17333 2082 dx-=1-z3diagskip;
17334 2082 z3step=2;
17335 2082 }
17336 else
17337 {
17338 193 dy+=1-z3diagskip;
17339 193 z3step=2;
17340 }
17341 2275 }
17342 else
17343 {
17344
2/2
✓ Branch 0 taken 11937 times.
✓ Branch 1 taken 87581 times.
99518 if(walkable)
17345 {
17346 87581 dx-=z3step-z3skip;
17347 87581 z3step=(z3step%2)+1;
17348 87581 }
17349 }
17350
17351 104620 break;
17352 }
17353 289313 }
17354 else
17355 {
17356
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 565661 times.
✓ Branch 2 taken 456444 times.
✓ Branch 3 taken 667540 times.
✓ Branch 4 taken 724746 times.
2414391 switch(d2)
17357 {
17358 case up:
17359
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 565353 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
565661 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
17360
17361 565661 break;
17362
17363 case down:
17364
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 456390 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
456444 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
17365
17366 456444 break;
17367
17368 case left:
17369 667540 dx-=xstep;
17370 667540 break;
17371
17372 case right:
17373 724746 dx+=xstep;
17374 724746 break;
17375 }
17376 }
17377 2703704 }
17378
17379
8/16
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 2703174 times.
✓ Branch 2 taken 2702895 times.
✓ Branch 3 taken 865 times.
✓ Branch 4 taken 2702699 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 2702699 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2702699 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
2703760 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
17380 {
17381 2702699 dir=d2;
17382 2702699 }
17383
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1061 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1061 else if (IsSideSwim() && get_bit(quest_rules,qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
17384 {
17385 dir = shiftdir;
17386 }
17387
17388
3/4
✓ Branch 0 taken 2663126 times.
✓ Branch 1 taken 40634 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2663126 times.
2703760 if(action != swimming && !IsSideSwim())
17389 {
17390 2663126 herostep();
17391
17392 //ack... don't walk if in midair! -DD
17393
12/14
✓ Branch 0 taken 2662540 times.
✓ Branch 1 taken 586 times.
✓ Branch 2 taken 2662261 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 2662101 times.
✓ Branch 5 taken 160 times.
✓ Branch 6 taken 2662101 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 149353 times.
✓ Branch 9 taken 2512748 times.
✓ Branch 10 taken 81755 times.
✓ Branch 11 taken 67598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 81755 times.
2663126 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y) && !getOnSideviewLadder()))
17394 {
17395 2580346 action=walking; FFCore.setHeroAction(walking);
17396 2580346 }
17397
17398
2/2
✓ Branch 0 taken 2522854 times.
✓ Branch 1 taken 140272 times.
2663126 if(++hero_count > (16*hero_animation_speed))
17399 140272 hero_count=0;
17400 2663126 }
17401
2/2
✓ Branch 0 taken 20310 times.
✓ Branch 1 taken 20324 times.
40634 else if(!(frame & 1))
17402 {
17403 20324 herostep();
17404 20324 }
17405
17406
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 2703174 times.
✓ Branch 2 taken 586 times.
✗ Branch 3 not taken.
2703760 if(charging==0 || attack!=wHammer)
17407 {
17408 2703760 sprite::move((zfix)dx,(zfix)dy);
17409 2703760 }
17410 2703760 }
17411
17412 12507931 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
17413 {
17414 12507931 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
17415 }
17416 12507931 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
17417 {
17418 12507931 WalkflagInfo ret;
17419
17420 12507931 wx = vbound(wx, -1, 256);
17421 12507931 wy = vbound(wy, -1, 176);
17422
17423
7/8
✓ Branch 0 taken 12458662 times.
✓ Branch 1 taken 49269 times.
✓ Branch 2 taken 12417182 times.
✓ Branch 3 taken 41480 times.
✓ Branch 4 taken 12417182 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1803 times.
✓ Branch 7 taken 12415379 times.
12507931 if (wx < 0 || wx > 255 || wy < 0 || wy > 175)
17424 {
17425 92552 ret.setUnwalkable(false);
17426 92552 return ret;
17427 }
17428
17429
2/2
✓ Branch 0 taken 41482 times.
✓ Branch 1 taken 12373897 times.
12415379 if(toogam)
17430 {
17431 41482 ret.setUnwalkable(false);
17432 41482 return ret;
17433 }
17434
17435
4/4
✓ Branch 0 taken 215929 times.
✓ Branch 1 taken 12157968 times.
✓ Branch 2 taken 214850 times.
✓ Branch 3 taken 1079 times.
12373897 if(blockpath && wy<(bigHitbox?80:88))
17436 {
17437 1079 ret.setUnwalkable(true);
17438 1079 return ret;
17439 }
17440
17441
4/4
✓ Branch 0 taken 85143 times.
✓ Branch 1 taken 12287675 times.
✓ Branch 2 taken 65126 times.
✓ Branch 3 taken 20017 times.
12372818 if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
17442 {
17443 20017 ret.setUnwalkable(true);
17444 20017 return ret;
17445 }
17446
17447
2/2
✓ Branch 0 taken 6275 times.
✓ Branch 1 taken 12346526 times.
12352801 if (collide_object(wx, wy,1, 1))
17448 {
17449 6275 ret.setUnwalkable(true);
17450 6275 return ret;
17451 }
17452
17453
14/20
✓ Branch 0 taken 7380358 times.
✓ Branch 1 taken 4966168 times.
✓ Branch 2 taken 7088293 times.
✓ Branch 3 taken 292065 times.
✓ Branch 4 taken 6842548 times.
✓ Branch 5 taken 245745 times.
✓ Branch 6 taken 245745 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 245745 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 138048 times.
✓ Branch 13 taken 107697 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 107697 times.
✓ Branch 16 taken 107697 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 17834 times.
✓ Branch 19 taken 12328692 times.
12502427 if(isdungeon() && currscr<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,SWITCHBLOCK_STATE))
17454
2/2
✓ Branch 0 taken 17853 times.
✓ Branch 1 taken 89844 times.
245745 && !get_bit(quest_rules,qr_FREEFORM))
17455 {
17456 17834 ret.setUnwalkable(true);
17457 17834 return ret;
17458 }
17459
17460
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12328692 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12328692 times.
12328692 bool wf = _walkflag(wx,wy,cnt,SWITCHBLOCK_STATE);
17461
17462
6/6
✓ Branch 0 taken 7362524 times.
✓ Branch 1 taken 4966168 times.
✓ Branch 2 taken 7070459 times.
✓ Branch 3 taken 292065 times.
✓ Branch 4 taken 2440258 times.
✓ Branch 5 taken 4630201 times.
12328692 if(isdungeon() && currscr<128 && !get_bit(quest_rules,qr_FREEFORM))
17463 {
17464
2/4
✓ Branch 0 taken 4630201 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4630201 times.
4630201 if((diagonalMovement||NO_GRIDLOCK))
17465 {
17466 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
17467
17468 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
17469 }
17470 4630201 }
17471 //All problems related to exiting water are probably here. -Z
17472
3/4
✓ Branch 0 taken 12027449 times.
✓ Branch 1 taken 301243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12027449 times.
12328692 if(action==swimming || IsSideSwim())
17473 {
17474
2/2
✓ Branch 0 taken 287131 times.
✓ Branch 1 taken 14112 times.
301243 if(!wf)
17475 {
17476 14112 bool isthissolid = false;
17477
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14112 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14112 times.
✓ Branch 4 taken 4262 times.
✓ Branch 5 taken 9850 times.
18374 if (_walkflag(x+7,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17478
4/6
✓ Branch 0 taken 9850 times.
✓ Branch 1 taken 4262 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4262 times.
14112 || _walkflag(x+7,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)
17479
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4262 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4262 times.
4262 || _walkflag(x+8,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE)
17480
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4262 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4262 times.
14112 || _walkflag(x+8,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE)) isthissolid = true;
17481 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
17482
17483
17484
5/6
✓ Branch 0 taken 6945 times.
✓ Branch 1 taken 7167 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6945 times.
✓ Branch 4 taken 6844 times.
✓ Branch 5 taken 20748 times.
21279 if(landswim>= (get_bit(quest_rules,qr_DROWN) && isSwimming() ? 1
17485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7167 times.
7167 : (!diagonalMovement) ? 1 : (get_bit(quest_rules,qr_NO_HOPPING)?1:22)))
17486 {
17487 //Check for out of bounds for swimming
17488 6844 bool changehop = true;
17489
17490
4/4
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 6122 times.
✓ Branch 2 taken 6122 times.
✓ Branch 3 taken 5608 times.
6844 if((diagonalMovement||NO_GRIDLOCK))
17491 {
17492
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12244 if(wx<0||wy<0)
17493 changehop = false;
17494 else if(wx>248)
17495 changehop = false;
17496 else if(wx>240&&cnt==2)
17497 changehop = false;
17498 else if(wy>168)
17499 changehop = false;
17500 }
17501
3/4
✓ Branch 0 taken 722 times.
✓ Branch 1 taken 4886 times.
✓ Branch 2 taken 5608 times.
✗ Branch 3 not taken.
5608 if ((get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
17502 //This may be where the hang-up for exiting water exists. -Z
17503 // hop out of the water
17504
2/2
✓ Branch 0 taken 4886 times.
✓ Branch 1 taken 722 times.
5608 if(changehop)
17505 722 ret.setHopClk(1);
17506 5608 }
17507 else
17508 {
17509
6/6
✓ Branch 0 taken 9250 times.
✓ Branch 1 taken 11498 times.
✓ Branch 2 taken 10195 times.
✓ Branch 3 taken 10553 times.
✓ Branch 4 taken 6413 times.
✓ Branch 5 taken 3782 times.
20748 if((!(get_bit(quest_rules, qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
17510 {
17511 //int32_t vx=((int32_t)x+4)&0xFFF8;
17512 //int32_t vy=((int32_t)y+4)&0xFFF8;
17513
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 2439 times.
10195 if(d2==left)
17514 {
17515
2/4
✓ Branch 0 taken 398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 398 times.
✗ Branch 3 not taken.
796 if(!iswaterex(MAPCOMBO(x-1,y+(bigHitbox?6:11)), currmap, currscr, -1, x-1,y+(bigHitbox?6:11)) &&
17516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 !iswaterex(MAPCOMBO(x-1,y+(bigHitbox?9:12)), currmap, currscr, -1, x-1,y+(bigHitbox?9:12)) &&
17517
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 398 times.
398 !_walkflag(x-1,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17518
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 398 times.
398 !_walkflag(x-1,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17519 {
17520 398 ret.setHopDir(d2);
17521 398 ret.setIlswim(true);
17522 398 }
17523 else ret.setIlswim(false);
17524 398 }
17525
2/2
✓ Branch 0 taken 2096 times.
✓ Branch 1 taken 343 times.
2439 else if(d2==right)
17526 {
17527
4/4
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1562 times.
✓ Branch 2 taken 534 times.
✓ Branch 3 taken 1562 times.
2630 if(!iswaterex(MAPCOMBO(x+16,y+(bigHitbox?6:11)), currmap, currscr, -1, x+16,y+(bigHitbox?6:11)) &&
17528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 534 times.
534 !iswaterex(MAPCOMBO(x+16,y+(bigHitbox?9:12)), currmap, currscr, -1, x+16,y+(bigHitbox?9:12)) &&
17529
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 534 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 534 times.
534 !_walkflag(x+16,y+(bigHitbox?6:11),1,SWITCHBLOCK_STATE) &&
17530
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 534 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 534 times.
534 !_walkflag(x+16,y+(bigHitbox?9:12),1,SWITCHBLOCK_STATE))
17531 {
17532 534 ret.setHopDir(d2);
17533 534 ret.setIlswim(true);
17534 534 }
17535 1562 else ret.setIlswim(false);
17536 2096 }
17537
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 else if(d2==up)
17538 {
17539
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
98 if(!iswaterex(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+7,y+(bigHitbox?0:8)-1) &&
17540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
49 !iswaterex(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), currmap, currscr, -1, x+8,y+(bigHitbox?0:8)-1) &&
17541
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49 times.
49 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE) &&
17542
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
49 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,SWITCHBLOCK_STATE))
17543 {
17544 49 ret.setHopDir(d2);
17545 49 ret.setIlswim(true);
17546 49 }
17547 else ret.setIlswim(false);
17548 49 }
17549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 else if(d2==down)
17550 {
17551
4/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 243 times.
345 if(!iswaterex(MAPCOMBO(x+7,y+16), currmap, currscr, -1, x+7,y+16) &&
17552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 !iswaterex(MAPCOMBO(x+8,y+16), currmap, currscr, -1, x+8,y+16) &&
17553
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
51 !_walkflag(x+7,y+16,1,SWITCHBLOCK_STATE) &&
17554
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
51 !_walkflag(x+8,y+16,1,SWITCHBLOCK_STATE))
17555 {
17556 51 ret.setHopDir(d2);
17557 51 ret.setIlswim(true);
17558 51 }
17559 243 else ret.setIlswim(false);
17560 294 }
17561 2837 }
17562
17563
2/4
✓ Branch 0 taken 13390 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13390 times.
13390 if(wx<0||wy<0);
17564
2/2
✓ Branch 0 taken 2138 times.
✓ Branch 1 taken 11252 times.
13390 else if(wx>248);
17565
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11252 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11252 else if(wx>240&&cnt==2);
17566
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 10938 times.
11252 else if(wy>168);
17567
3/4
✓ Branch 0 taken 6106 times.
✓ Branch 1 taken 4832 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6106 times.
10938 else if(get_bit(quest_rules, qr_DROWN) && !ilswim);
17568 //if(iswaterex(MAPCOMBO(wx,wy)) && iswaterex(MAPCOMBO(wx,wy)))
17569
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4814 times.
4832 else if(iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
17570 {
17571 18 ret.setUnwalkable(false);
17572 18 return ret;
17573 }
17574 else
17575 {
17576 4814 ret.setUnwalkable(true);
17577 4814 return ret;
17578 }
17579 }
17580 14166 }
17581 else
17582 {
17583 287131 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17584 287131 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Is x + 8 intentional???
17585
17586
8/8
✓ Branch 0 taken 266189 times.
✓ Branch 1 taken 20942 times.
✓ Branch 2 taken 239191 times.
✓ Branch 3 taken 26998 times.
✓ Branch 4 taken 20942 times.
✓ Branch 5 taken 26998 times.
✓ Branch 6 taken 14494 times.
✓ Branch 7 taken 6448 times.
287131 if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17587 {
17588 253685 ret.setUnwalkable(false);
17589 253685 return ret;
17590 }
17591 }
17592 47612 }
17593
2/2
✓ Branch 0 taken 240709 times.
✓ Branch 1 taken 11786740 times.
12027449 else if(ladderx+laddery) // ladder is being used
17594 {
17595
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 234699 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
240709 int32_t lx = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wx) : x;
17596
7/10
✓ Branch 0 taken 6010 times.
✓ Branch 1 taken 234699 times.
✓ Branch 2 taken 5957 times.
✓ Branch 3 taken 53 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 53 times.
240709 int32_t ly = !(get_bit(quest_rules, qr_DROWN)&&iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,SWITCHBLOCK_STATE)) ? zfix(wy) : y;
17597
17598
3/4
✓ Branch 0 taken 240560 times.
✓ Branch 1 taken 149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240560 times.
240709 if((diagonalMovement||NO_GRIDLOCK))
17599 {
17600
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 if(ladderdir==up)
17601 {
17602 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
17603 {
17604 bool temp = false;
17605
17606 if(!(abs(lx-(ladderx+8))<=8))
17607 temp = true;
17608
17609 if(cnt==2)
17610 if(!(abs((lx+8)-(ladderx+8))<=8))
17611 temp=true;
17612
17613 if(!temp)
17614 {
17615 ret.setUnwalkable(false);
17616 return ret;
17617 }
17618
17619 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
17620 {
17621 ret.setUnwalkable(true);
17622 return ret;
17623 }
17624 }
17625 }
17626 else
17627 {
17628
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 71 times.
149 if(abs(lx-(ladderx+8))<=8)
17629 {
17630
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 49 times.
71 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
17631 {
17632 22 ret.setUnwalkable(false);
17633 22 return ret;
17634 }
17635
17636
5/6
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24 times.
49 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
17637 {
17638 13 ret.setUnwalkable(true);
17639 13 return ret;
17640 }
17641
17642
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
36 if((abs(ly-laddery+8)<=8) && d2<=down)
17643 {
17644 ret.setUnwalkable(false);
17645 return ret;
17646 }
17647 36 }
17648 }
17649 114 } // diagonalMovement
17650 else
17651 {
17652
2/2
✓ Branch 0 taken 142668 times.
✓ Branch 1 taken 97892 times.
240560 if((d2&2)==ladderdir) // same direction
17653 {
17654
3/3
✓ Branch 0 taken 8625 times.
✓ Branch 1 taken 126385 times.
✓ Branch 2 taken 7658 times.
142668 switch(d2)
17655 {
17656 case up:
17657
2/2
✓ Branch 0 taken 5274 times.
✓ Branch 1 taken 2384 times.
7658 if(y.getInt()<=laddery)
17658 {
17659
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5274 times.
✓ Branch 4 taken 293 times.
✓ Branch 5 taken 4981 times.
10255 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,SWITCHBLOCK_STATE) ||
17660
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4981 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4981 times.
4981 _walkflag(ladderx+8,laddery-8,1,SWITCHBLOCK_STATE));
17661 5274 return ret;
17662
17663 }
17664
17665 [[fallthrough]];
17666 case down:
17667
2/2
✓ Branch 0 taken 5898 times.
✓ Branch 1 taken 5111 times.
11009 if((wy&0xF0)==laddery)
17668 {
17669 5898 ret.setUnwalkable(false);
17670 5898 return ret;
17671 }
17672
17673 5111 break;
17674
17675 default:
17676
2/2
✓ Branch 0 taken 49797 times.
✓ Branch 1 taken 76588 times.
126385 if((wx&0xF0)==ladderx)
17677 {
17678 49797 ret.setUnwalkable(false);
17679 49797 return ret;
17680 }
17681 76588 }
17682
17683
2/2
✓ Branch 0 taken 5111 times.
✓ Branch 1 taken 76588 times.
81699 if(d2<=down)
17684 {
17685
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5111 times.
✓ Branch 2 taken 5111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 534 times.
✓ Branch 5 taken 4577 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4577 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 4577 times.
5111 ret.setUnwalkable(_walkflag(ladderx,wy,1,SWITCHBLOCK_STATE) || _walkflag(ladderx+8,wy,1,SWITCHBLOCK_STATE));
17686 5111 return ret;
17687 }
17688
17689
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 76588 times.
✓ Branch 2 taken 76588 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14148 times.
✓ Branch 5 taken 62440 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 62440 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 62440 times.
76588 ret.setUnwalkable(_walkflag((wx&0xF0),wy,1,SWITCHBLOCK_STATE) || _walkflag((wx&0xF0)+8,wy,1,SWITCHBLOCK_STATE));
17690 76588 return ret;
17691 }
17692
17693 // different dir
17694
3/8
✓ Branch 0 taken 97463 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97463 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
97892 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
17695 {
17696 97463 ret.setUnwalkable(true);
17697 97463 return ret;
17698 }
17699
17700
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
17701 {
17702 20 ret.setUnwalkable(false);
17703 20 return ret;
17704 }
17705 }
17706 523 }
17707
6/6
✓ Branch 0 taken 9843196 times.
✓ Branch 1 taken 1943544 times.
✓ Branch 2 taken 9531483 times.
✓ Branch 3 taken 311713 times.
✓ Branch 4 taken 1460019 times.
✓ Branch 5 taken 8071464 times.
11786740 else if(wf || isSideViewHero() || get_bit(quest_rules, qr_DROWN))
17708 {
17709 // see if it's a good spot for the ladder or for swimming
17710
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3715276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3715276 times.
3715276 bool unwalkablex = _walkflag(wx,wy,1,SWITCHBLOCK_STATE); //will be used later for the ladder -DD
17711
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3715276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3715276 times.
3715276 bool unwalkablex8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE);
17712
17713
2/2
✓ Branch 0 taken 2289762 times.
✓ Branch 1 taken 1425514 times.
3715276 if(get_bit(quest_rules, qr_DROWN))
17714 {
17715 // Drowning changes the following attributes:
17716 // * Dangerous water is also walkable, so ignore the previous
17717 // definitions of unwalkablex and unwalkablex8.
17718 // * Instead, prevent the ladder from being used in the
17719 // one frame where Hero has landed on water before drowning.
17720 2289762 unwalkablex = unwalkablex8 = !iswaterex(MAPCOMBO(x+4,y+11), currmap, currscr, -1, x+4,y+11);
17721 2289762 }
17722
17723 // check if he can swim
17724
5/6
✓ Branch 0 taken 1174912 times.
✓ Branch 1 taken 2540364 times.
✓ Branch 2 taken 1174696 times.
✓ Branch 3 taken 216 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1174696 times.
3715276 if(current_item(itype_flippers) && z==0 && fakez==0)
17725 {
17726 1174696 int32_t wtrx = iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy);
17727 1174696 int32_t wtrx8 = iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
17728
2/6
✓ Branch 0 taken 1174696 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1174696 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1174696 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3))) //Don't swim if the water's required level is too high! -Dimi
17729 {
17730 //ladder ignores water combos that are now walkable thanks to flippers -DD
17731
2/2
✓ Branch 0 taken 4165 times.
✓ Branch 1 taken 1170531 times.
1174696 unwalkablex = unwalkablex && (!wtrx);
17732
2/2
✓ Branch 0 taken 432026 times.
✓ Branch 1 taken 742670 times.
1174696 unwalkablex8 = unwalkablex8 && (!wtrx8);
17733
17734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1174696 times.
1174696 if(landswim >= 22)
17735 {
17736 ret.setHopClk(2);
17737 ret.setUnwalkable(false);
17738 return ret;
17739 }
17740
8/8
✓ Branch 0 taken 1032811 times.
✓ Branch 1 taken 141885 times.
✓ Branch 2 taken 4724 times.
✓ Branch 3 taken 1028087 times.
✓ Branch 4 taken 141885 times.
✓ Branch 5 taken 1028087 times.
✓ Branch 6 taken 328 times.
✓ Branch 7 taken 141557 times.
1174696 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
17741 {
17742
3/4
✓ Branch 0 taken 4591 times.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4591 times.
5052 if(!(diagonalMovement||NO_GRIDLOCK))
17743 {
17744 4591 ret.setHopClk(2);
17745
17746
2/4
✓ Branch 0 taken 4591 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4591 times.
4591 if(charging || spins>5)
17747 {
17748 //if Hero is charging, he might be facing the wrong direction (we want him to
17749 //hop into the water, not in the facing direction)
17750 ret.setDir(d2);
17751 //moreover Hero can't charge in the water -DD
17752 ret.setChargeAttack();
17753 }
17754
17755 4591 ret.setUnwalkable(false);
17756 4591 return ret;
17757 }
17758
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 336 times.
461 else if(dir==d2)
17759 {
17760 336 ret.setIlswim(true);
17761 336 ladderx = 0;
17762 336 laddery = 0;
17763 336 }
17764 461 }
17765 1170105 }
17766 1170105 }
17767
17768 // check if he can use the ladder
17769 // "Allow Ladder Anywhere" is toggled by fLADDER
17770
2/2
✓ Branch 0 taken 2583700 times.
✓ Branch 1 taken 1126985 times.
3710685 if(can_deploy_ladder())
17771 // laddersetup
17772 {
17773 // Check if there's water to use the ladder over
17774 1126985 bool wtrx = (iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy) != 0);
17775 1126985 bool wtrx8 = (iswaterex(MAPCOMBO(x+8,wy), currmap, currscr, -1, x+8,wy) != 0);
17776 1126985 int32_t ldrid = current_item_id(itype_ladder);
17777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1126985 times.
1126985 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&ITEM_FLAG1);
17778
17779
4/4
✓ Branch 0 taken 1120277 times.
✓ Branch 1 taken 6708 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 1120260 times.
1126985 if(wtrx || wtrx8)
17780 {
17781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6725 times.
6725 if(isSideViewHero())
17782 {
17783 wtrx = !_walkflag(wx, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17784 wtrx8 = !_walkflag(wx+8, wy+8, 1,SWITCHBLOCK_STATE) && !_walkflag(wx+8, wy, 1,SWITCHBLOCK_STATE) && dir!=down;
17785 }
17786 // * walk on half-water using the ladder instead of using flippers.
17787 // * otherwise, walk on ladder(+hookshot) combos.
17788
3/8
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 6310 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6725 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
17789 {
17790
2/2
✓ Branch 0 taken 387 times.
✓ Branch 1 taken 28 times.
415 if(!get_bit(quest_rules, qr_OLD_210_WATER))
17791 {
17792 //if Hero could swim on a tile instead of using the ladder,
17793 //refuse to use the ladder to step over that tile. -DD
17794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
17795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 387 times.
387 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
17796 387 }
17797 415 }
17798 6725 }
17799 else
17800 {
17801 // No water; check other things
17802
17803 //Check pits
17804
2/2
✓ Branch 0 taken 1119233 times.
✓ Branch 1 taken 1027 times.
1120260 if(ladderpits)
17805 {
17806 1027 int32_t pit_cmb = getpitfall(wx,wy);
17807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17808 1027 pit_cmb = getpitfall(x+8,wy);
17809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
17810 1027 }
17811
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1119233 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
1120260 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
17812 {
17813 1120260 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
17814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1120260 times.
1120260 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17815 1120260 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
17816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1120260 times.
1120260 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
17817 1120260 }
17818 }
17819
17820
2/2
✓ Branch 0 taken 2253970 times.
✓ Branch 1 taken 1126985 times.
3380955 for (int32_t i = 0; i <= 1; ++i)
17821 {
17822
2/2
✓ Branch 0 taken 1867246 times.
✓ Branch 1 taken 386724 times.
2253970 if(tmpscr2[i].valid!=0)
17823 {
17824
2/2
✓ Branch 0 taken 319092 times.
✓ Branch 1 taken 67632 times.
386724 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
17825 {
17826
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319092 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319092 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17827
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 319092 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
319092 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17828 319092 }
17829 else
17830 {
17831
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 67373 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
67632 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,1, &(tmpscr2[i]))) wtrx = false;
17832
3/4
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 67395 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 237 times.
67632 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,1, &(tmpscr2[i]))) wtrx8 = false;
17833 }
17834 386724 }
17835 2253970 }
17836
2/2
✓ Branch 0 taken 945358 times.
✓ Branch 1 taken 181627 times.
1126985 bool walkwater = (get_bit(quest_rules, qr_DROWN) && !iswaterex(MAPCOMBO(wx,wy), currmap, currscr, -1, wx,wy));
17837
17838
3/4
✓ Branch 0 taken 1085318 times.
✓ Branch 1 taken 41667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1085318 times.
1126985 if((diagonalMovement||NO_GRIDLOCK))
17839 {
17840
2/2
✓ Branch 0 taken 12170 times.
✓ Branch 1 taken 29497 times.
41667 if(d2==dir)
17841 {
17842 29497 int32_t c = walkwater ? 0:8;
17843 29497 int32_t b = walkwater ? 8:0;
17844
17845
2/2
✓ Branch 0 taken 21700 times.
✓ Branch 1 taken 7797 times.
29497 if(d2>=left)
17846 {
17847 // If the difference between wy and y is small enough
17848
4/4
✓ Branch 0 taken 6371 times.
✓ Branch 1 taken 15329 times.
✓ Branch 2 taken 21697 times.
✓ Branch 3 taken 3 times.
21700 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
17849 {
17850 // Don't activate the ladder if it would be entirely
17851 // over water and Hero has the flippers. This isn't
17852 // a good way to do this, but it's too risky
17853 // to make big changes to this stuff.
17854 3 bool deployLadder=true;
17855 3 int32_t lx=wx&0xF0;
17856
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
3 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex(MAPCOMBO(lx+8, y+8), currmap, currscr, -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
17857 {
17858
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(iswaterex(MAPCOMBO(lx, y), currmap, currscr, -1, lx, y) &&
17859 iswaterex(MAPCOMBO(lx+15, y), currmap, currscr, -1, lx+15, y) &&
17860 iswaterex(MAPCOMBO(lx, y+15), currmap, currscr, -1, lx, y+15) &&
17861 iswaterex(MAPCOMBO(lx+15, y+15), currmap, currscr, -1, lx+15, y+15))
17862 deployLadder=false;
17863 2 }
17864
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(deployLadder)
17865 {
17866 3 ladderx = wx&0xF0;
17867 3 laddery = y;
17868 3 ladderdir = left;
17869 3 ladderstart = d2;
17870 3 ret.setUnwalkable(laddery!=y.getInt());
17871 3 return ret;
17872 }
17873 }
17874 21697 }
17875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7797 times.
7797 else if(d2<=down)
17876 {
17877 // If the difference between wx and x is small enough
17878
3/4
✓ Branch 0 taken 2954 times.
✓ Branch 1 taken 4843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7797 times.
7797 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
17879 {
17880 ladderx = x;
17881 laddery = wy&0xF0;
17882 ladderdir = up;
17883 ladderstart = d2;
17884 ret.setUnwalkable(ladderx!=x.getInt());
17885 return ret;
17886 }
17887
17888
2/2
✓ Branch 0 taken 2954 times.
✓ Branch 1 taken 4843 times.
7797 if(cnt==2)
17889 {
17890
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4843 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4843 times.
4843 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
17891 {
17892 ladderx = x;
17893 laddery = wy&0xF0;
17894 ladderdir = up;
17895 ladderstart = d2;
17896 ret.setUnwalkable(ladderx!=x.getInt());
17897 return ret;
17898 }
17899 4843 }
17900 7797 }
17901 29494 }
17902 41664 }
17903 else
17904 {
17905
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1085318 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1085318 times.
✓ Branch 4 taken 109083 times.
✓ Branch 5 taken 976235 times.
1085318 bool flgx = _walkflag(wx,wy,1,SWITCHBLOCK_STATE) && !wtrx; // Solid, and not steppable
17906
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1085318 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1085318 times.
✓ Branch 4 taken 1016443 times.
✓ Branch 5 taken 68875 times.
1085318 bool flgx8 = _walkflag(x+8,wy,1,SWITCHBLOCK_STATE) && !wtrx8; // Solid, and not steppable
17907
17908
2/2
✓ Branch 0 taken 999712 times.
✓ Branch 1 taken 85606 times.
1085353 if((d2>=left && wtrx)
17909 // Deploy the ladder vertically even if Hero is only half on water.
17910
8/8
✓ Branch 0 taken 11641 times.
✓ Branch 1 taken 988071 times.
✓ Branch 2 taken 85606 times.
✓ Branch 3 taken 988071 times.
✓ Branch 4 taken 786 times.
✓ Branch 5 taken 84820 times.
✓ Branch 6 taken 35 times.
✓ Branch 7 taken 85571 times.
1085318 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
17911 {
17912
4/4
✓ Branch 0 taken 11299 times.
✓ Branch 1 taken 342 times.
✓ Branch 2 taken 476 times.
✓ Branch 3 taken 10823 times.
11641 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
17913 818 ladderdir = up;
17914 else
17915 10823 ladderdir = left;
17916
17917
2/2
✓ Branch 0 taken 10823 times.
✓ Branch 1 taken 818 times.
11641 if(ladderdir==up)
17918 {
17919 818 ladderx = x.getInt()&0xF8;
17920 818 laddery = wy&0xF0;
17921 818 }
17922 else
17923 {
17924 10823 ladderx = wx&0xF0;
17925 10823 laddery = y.getInt()&0xF8;
17926 }
17927
17928 11641 ret.setUnwalkable(false);
17929 11641 return ret;
17930 }
17931 }
17932 1115341 }
17933 3699041 }
17934
17935 11818640 ret.setUnwalkable(wf);
17936 11818640 return ret;
17937 12512817 }
17938
17939 // Only checks for moving blocks. Apparently this is a thing we need.
17940 1167371 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
17941 {
17942 1167371 HeroClass::WalkflagInfo ret;
17943
2/2
✓ Branch 0 taken 10214 times.
✓ Branch 1 taken 1157157 times.
1167371 if (!blockmoving) //Without this, weird swimming behaviors happen.
17944 {
17945 1157157 ret.setFlags(~1);
17946 1157157 ret.setHopDir(-1);
17947 1157157 }
17948
2/2
✓ Branch 0 taken 2636 times.
✓ Branch 1 taken 1164735 times.
1167371 if(toogam) return ret;
17949
2/2
✓ Branch 0 taken 1154521 times.
✓ Branch 1 taken 10214 times.
1164735 if (blockmoving)
17950 10214 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
17951
2/2
✓ Branch 0 taken 1164212 times.
✓ Branch 1 taken 523 times.
1164735 if (collide_object(wx, wy,1, 1))
17952 523 ret.setUnwalkable(true);
17953 1164735 return ret;
17954 1167371 }
17955
17956 5002129 bool HeroClass::checksoliddamage()
17957 {
17958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5002129 times.
5002129 if(toogam) return false;
17959
17960
2/4
✓ Branch 0 taken 5002129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5002129 times.
5002129 if(z!=0||fakez!=0) return false;
17961 5002129 int32_t bx = x.getInt();
17962 5002129 int32_t by = y.getInt();
17963 5002129 int32_t initk = 0;
17964
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1184036 times.
✓ Branch 2 taken 952586 times.
✓ Branch 3 taken 1376585 times.
✓ Branch 4 taken 1488922 times.
5002129 switch(dir)
17965 {
17966 case up:
17967
17968 1184036 by-=bigHitbox ? 4 : -4;
17969
17970
1/2
✓ Branch 0 taken 1184036 times.
✗ Branch 1 not taken.
1184036 if(by<0)
17971 {
17972 return false;
17973 }
17974 1184036 break;
17975
17976 case down:
17977
17978 952586 by+=20;
17979
2/2
✓ Branch 0 taken 8337 times.
✓ Branch 1 taken 944249 times.
952586 if(by>175)
17980 {
17981 8337 return false;
17982 }
17983
17984 944249 break;
17985
17986 case left:
17987 1376585 bx-=4;
17988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1376585 times.
1376585 if (!bigHitbox)
17989 {
17990 1376585 by+=8;
17991 1376585 initk = 1;
17992 1376585 }
17993
2/2
✓ Branch 0 taken 1369583 times.
✓ Branch 1 taken 7002 times.
1376585 if(bx<0)
17994 {
17995 7002 return false;
17996 }
17997
17998 1369583 break;
17999
18000 case right:
18001
18002 1488922 bx+=20;
18003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1488922 times.
1488922 if (!bigHitbox)
18004 {
18005 1488922 by+=8;
18006 1488922 initk = 1;
18007 1488922 }
18008
2/2
✓ Branch 0 taken 9679 times.
✓ Branch 1 taken 1479243 times.
1488922 if(bx>255)
18009 {
18010 9679 return false;
18011 }
18012
18013 1479243 break;
18014 }
18015 4977111 newcombo const& cmb = combobuf[MAPCOMBO(bx,by)];
18016 4977111 int32_t t = cmb.type;
18017
2/2
✓ Branch 0 taken 4976995 times.
✓ Branch 1 taken 116 times.
4977111 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
18018 116 t = cNONE;
18019 4977111 int32_t initbx = bx;
18020 4977111 int32_t initby = by;
18021
18022 // Unlike push blocks, damage combos should be tested on layers 2 and under
18023
2/2
✓ Branch 0 taken 8901905 times.
✓ Branch 1 taken 4977095 times.
13879000 for(int32_t i=(get_bit(quest_rules,qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
18024 {
18025 8901905 bx = initbx;
18026 8901905 by = initby;
18027
2/2
✓ Branch 0 taken 21563226 times.
✓ Branch 1 taken 8901889 times.
30465115 for (int32_t k = initk; k <= 2; k++)
18028 {
18029 21563226 newcombo const& cmb = combobuf[FFCore.tempScreens[i]->data[COMBOPOS(bx,by)]];
18030 21563226 t = cmb.type;
18031
2/2
✓ Branch 0 taken 21562900 times.
✓ Branch 1 taken 326 times.
21563226 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
18032 326 t = cNONE;
18033 // Solid damage combos use pushing>0, hence the code is here.
18034
10/10
✓ Branch 0 taken 368425 times.
✓ Branch 1 taken 21194801 times.
✓ Branch 2 taken 92953 times.
✓ Branch 3 taken 275472 times.
✓ Branch 4 taken 87274 times.
✓ Branch 5 taken 5679 times.
✓ Branch 6 taken 1683 times.
✓ Branch 7 taken 85591 times.
✓ Branch 8 taken 18 times.
✓ Branch 9 taken 1665 times.
21563226 if (!get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
18035 {
18036
14/18
✓ Branch 0 taken 21545434 times.
✓ Branch 1 taken 10448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10448 times.
✓ Branch 4 taken 10448 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1145 times.
✓ Branch 7 taken 9303 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 992 times.
✓ Branch 10 taken 60 times.
✓ Branch 11 taken 93 times.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 60 times.
✓ Branch 16 taken 21555822 times.
✓ Branch 17 taken 60 times.
21555882 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,SWITCHBLOCK_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting && !get_bit(quest_rules, qr_NOSOLIDDAMAGECOMBOS))
18037 {
18038 // Bite Hero
18039
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 6 times.
60 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
18040 54 }
18041 21555876 }
18042
3/4
✓ Branch 0 taken 819929 times.
✓ Branch 1 taken 20743291 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 758111 times.
22321331 if(isSideViewHero() && // Check for sideview damage combos
18043
3/4
✓ Branch 0 taken 758111 times.
✓ Branch 1 taken 61818 times.
✓ Branch 2 taken 758111 times.
✗ Branch 3 not taken.
819929 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
18044 {
18045
2/2
✓ Branch 0 taken 87637 times.
✓ Branch 1 taken 670474 times.
758111 if (get_bit(quest_rules, qr_LESS_AWFUL_SIDESPIKES))
18046 {
18047
4/6
✓ Branch 0 taken 87637 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 87619 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
87637 if (on_sideview_solid_oldpos(x,y,old_x,old_y) && (!getOnSideviewLadder() || DrunkDown()))
18048 {
18049
4/4
✓ Branch 0 taken 87610 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 87614 times.
✓ Branch 3 taken 5 times.
87619 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
18050 {
18051
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
18052 }
18053 87614 }
18054
1/2
✓ Branch 0 taken 87632 times.
✗ Branch 1 not taken.
87632 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
18055 87632 }
18056 else
18057 {
18058 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
18059
1/2
✓ Branch 0 taken 670474 times.
✗ Branch 1 not taken.
670474 if ( get_bit(quest_rules, qr_OLDSIDEVIEWSPIKES ) )
18060 {
18061
2/2
✓ Branch 0 taken 670469 times.
✓ Branch 1 taken 5 times.
1340948 if (checkdamagecombos(x+8-(zfix)(tmpscr->csensitive),
18062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 x+8+(zc_max(tmpscr->csensitive-1,0)),
18063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
670474 y+17-(get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2),
18064
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 670474 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 670474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
670474 y+17+zc_max((get_bit(quest_rules,qr_LTTPCOLLISION)?tmpscr->csensitive:(tmpscr->csensitive+1)/2)-1,0), i-1, true))
18065 5 return true;
18066 670469 }
18067 else //2.50.1 and later
18068 {
18069 if(checkdamagecombos(x+4, x+12, y+16, y+24))
18070 return true;
18071 }
18072 }
18073
18074 758101 }
18075
2/2
✓ Branch 0 taken 11278296 times.
✓ Branch 1 taken 10284914 times.
21563210 if (dir < left) bx += (k % 2) ? 7 : 8;
18076 10284914 else by += (k % 2) ? 7 : 8;
18077 21563210 }
18078 8901889 }
18079 4977095 return false;
18080 5002129 }
18081 5145819 void HeroClass::checkpushblock()
18082 {
18083
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 5132413 times.
5145819 if(toogam) return;
18084
18085
3/4
✓ Branch 0 taken 5129144 times.
✓ Branch 1 taken 3269 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5129144 times.
5132413 if(z!=0||fakez!=0) return;
18086
18087 // Return early in some cases..
18088 5129144 bool earlyReturn=false;
18089
18090
4/4
✓ Branch 0 taken 4474454 times.
✓ Branch 1 taken 654690 times.
✓ Branch 2 taken 4697345 times.
✓ Branch 3 taken 431799 times.
5129144 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
18091
2/2
✓ Branch 0 taken 1722565 times.
✓ Branch 1 taken 2974780 times.
4697345 if(x.getInt()&15) earlyReturn=true;
18092
18093 // if(y<16) return;
18094
4/4
✓ Branch 0 taken 257631 times.
✓ Branch 1 taken 4871513 times.
✓ Branch 2 taken 130616 times.
✓ Branch 3 taken 127015 times.
5129144 if(isSideViewHero() && !on_sideview_solid_oldpos(x,y,old_x,old_y)) return;
18095
18096 5002129 int32_t bx = x.getInt()&0xF0;
18097 5002129 int32_t by = (y.getInt()&0xF0);
18098
18099
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1184036 times.
✓ Branch 2 taken 952586 times.
✓ Branch 3 taken 1376585 times.
✓ Branch 4 taken 1488922 times.
5002129 switch(dir)
18100 {
18101 case up:
18102
2/2
✓ Branch 0 taken 39155 times.
✓ Branch 1 taken 1144881 times.
1184036 if(y<16)
18103 {
18104 39155 earlyReturn=true;
18105 39155 break;
18106 }
18107
18108
3/4
✓ Branch 0 taken 208089 times.
✓ Branch 1 taken 936792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 208089 times.
1144881 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18109
18110
2/2
✓ Branch 0 taken 650496 times.
✓ Branch 1 taken 494385 times.
1144881 if((int32_t)x&8) bx+=16;
18111
18112 1144881 break;
18113
18114 case down:
18115
2/2
✓ Branch 0 taken 59112 times.
✓ Branch 1 taken 893474 times.
952586 if(y>128)
18116 {
18117 59112 earlyReturn=true;
18118 59112 break;
18119 }
18120 else
18121 {
18122 893474 by+=16;
18123
18124
2/2
✓ Branch 0 taken 568147 times.
✓ Branch 1 taken 325327 times.
893474 if((int32_t)x&8) bx+=16;
18125 }
18126
18127 893474 break;
18128
18129 case left:
18130
2/2
✓ Branch 0 taken 67092 times.
✓ Branch 1 taken 1309493 times.
1376585 if(x<32)
18131 {
18132 67092 earlyReturn=true;
18133 67092 break;
18134 }
18135 else
18136 {
18137 1309493 bx-=16;
18138
18139
2/2
✓ Branch 0 taken 837629 times.
✓ Branch 1 taken 471864 times.
1309493 if(y.getInt()&8)
18140 {
18141 471864 by+=16;
18142 471864 }
18143 }
18144
18145 1309493 break;
18146
18147 case right:
18148
2/2
✓ Branch 0 taken 68200 times.
✓ Branch 1 taken 1420722 times.
1488922 if(x>208)
18149 {
18150 68200 earlyReturn=true;
18151 68200 break;
18152 }
18153 else
18154 {
18155 1420722 bx+=16;
18156
18157
2/2
✓ Branch 0 taken 927886 times.
✓ Branch 1 taken 492836 times.
1420722 if(y.getInt()&8)
18158 {
18159 492836 by+=16;
18160 492836 }
18161 }
18162
18163 1420722 break;
18164 }
18165
18166
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 5002113 times.
5002129 if (checksoliddamage()) return;
18167
18168
2/2
✓ Branch 0 taken 3016898 times.
✓ Branch 1 taken 1985215 times.
5002113 if(earlyReturn)
18169 3016898 return;
18170
18171 1985215 int32_t itemid=current_item_id(itype_bracelet);
18172 1985215 size_t combopos = (by&0xF0)+(bx>>4);
18173
2/2
✓ Branch 0 taken 713156 times.
✓ Branch 1 taken 1272059 times.
1985215 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & ITEM_FLAG1);
18174
2/2
✓ Branch 0 taken 1272059 times.
✓ Branch 1 taken 713156 times.
1985215 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
18175
2/2
✓ Branch 0 taken 1987555 times.
✓ Branch 1 taken 3390424 times.
5377979 for(int lyr = 2; lyr > -1; --lyr) //Top-down, in case of stacked push blocks
18176 {
18177
4/4
✓ Branch 0 taken 1795531 times.
✓ Branch 1 taken 1594893 times.
✓ Branch 2 taken 512921 times.
✓ Branch 3 taken 1282610 times.
3390424 if(get_bit(quest_rules,qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
18178
4/4
✓ Branch 0 taken 1405210 times.
✓ Branch 1 taken 702604 times.
✓ Branch 2 taken 1396676 times.
✓ Branch 3 taken 8534 times.
2107814 if(lyr && !get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
18179 1396676 continue;
18180 711138 mapscr* m = FFCore.tempScreens[lyr];
18181 711138 int32_t f = MAPFLAG2(lyr-1,bx,by);
18182 711138 int32_t f2 = MAPCOMBOFLAG2(lyr-1,bx,by);
18183
2/2
✓ Branch 0 taken 8534 times.
✓ Branch 1 taken 702604 times.
711138 int32_t t = lyr == 0 ?
18184 702604 combobuf[MAPCOMBO(bx,by)].type :
18185 8534 combobuf[MAPCOMBOL(lyr,bx,by)].type;
18186
18187
8/8
✓ Branch 0 taken 649577 times.
✓ Branch 1 taken 61561 times.
✓ Branch 2 taken 646818 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 20014 times.
✓ Branch 5 taken 691124 times.
✓ Branch 6 taken 642722 times.
✓ Branch 7 taken 662736 times.
711138 if((t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) && (pushing<16 || hasMainGuy())) continue;
18188
18189
8/8
✓ Branch 0 taken 661700 times.
✓ Branch 1 taken 1036 times.
✓ Branch 2 taken 658336 times.
✓ Branch 3 taken 3364 times.
✓ Branch 4 taken 657777 times.
✓ Branch 5 taken 559 times.
✓ Branch 6 taken 1182 times.
✓ Branch 7 taken 663318 times.
668281 if((t==cPUSH_HW || t==cPUSH_HEAVY || t==cPUSH_HEAVY2 || t==cPUSH_HW2)
18190
8/8
✓ Branch 0 taken 1178 times.
✓ Branch 1 taken 658955 times.
✓ Branch 2 taken 4896 times.
✓ Branch 3 taken 649 times.
✓ Branch 4 taken 559 times.
✓ Branch 5 taken 4337 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 4363 times.
667099 && (itemid<0 || glove->power<((t==cPUSH_HEAVY2 || t==cPUSH_HW2)?2:1) ||
18191
3/4
✓ Branch 0 taken 4357 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
5545 (limitedpush && usecounts[itemid] > zc_max(1, glove->misc3)))) continue;
18192
18193 663318 bool doit=false;
18194 663318 bool changeflag=false;
18195 663318 bool changecombo=false;
18196
18197
8/8
✓ Branch 0 taken 661674 times.
✓ Branch 1 taken 1644 times.
✓ Branch 2 taken 661670 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 929 times.
✓ Branch 5 taken 662389 times.
✓ Branch 6 taken 323 times.
✓ Branch 7 taken 660502 times.
1324143 if(((f==mfPUSHUD || f==mfPUSHUDNS|| f==mfPUSHUDINS) && dir<=down) ||
18198
4/4
✓ Branch 0 taken 661692 times.
✓ Branch 1 taken 697 times.
✓ Branch 2 taken 661690 times.
✓ Branch 3 taken 2 times.
662389 ((f==mfPUSHLR || f==mfPUSHLRNS|| f==mfPUSHLRINS) && dir>=left) ||
18199
4/4
✓ Branch 0 taken 661709 times.
✓ Branch 1 taken 680 times.
✓ Branch 2 taken 661584 times.
✓ Branch 3 taken 125 times.
662389 ((f==mfPUSHU || f==mfPUSHUNS || f==mfPUSHUINS) && dir==up) ||
18200
3/4
✓ Branch 0 taken 661670 times.
✓ Branch 1 taken 719 times.
✓ Branch 2 taken 661670 times.
✗ Branch 3 not taken.
662389 ((f==mfPUSHD || f==mfPUSHDNS || f==mfPUSHDINS) && dir==down) ||
18201
3/4
✓ Branch 0 taken 661578 times.
✓ Branch 1 taken 811 times.
✓ Branch 2 taken 661578 times.
✗ Branch 3 not taken.
662389 ((f==mfPUSHL || f==mfPUSHLNS || f==mfPUSHLINS) && dir==left) ||
18202
3/4
✓ Branch 0 taken 661606 times.
✓ Branch 1 taken 729 times.
✓ Branch 2 taken 661606 times.
✗ Branch 3 not taken.
662335 ((f==mfPUSHR || f==mfPUSHRNS || f==mfPUSHRINS) && dir==right) ||
18203
2/2
✓ Branch 0 taken 660825 times.
✓ Branch 1 taken 52 times.
660877 f==mfPUSH4 || f==mfPUSH4NS || f==mfPUSH4INS)
18204 {
18205 1304 changeflag=true;
18206 1304 doit=true;
18207 1304 }
18208
18209
7/8
✓ Branch 0 taken 661786 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 661786 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 661796 times.
✓ Branch 6 taken 661785 times.
✓ Branch 7 taken 1 times.
1323582 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
18210
3/4
✓ Branch 0 taken 661786 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 661786 times.
✗ Branch 3 not taken.
661796 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
18211
3/4
✓ Branch 0 taken 661786 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 661786 times.
✗ Branch 3 not taken.
661796 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
18212
3/4
✓ Branch 0 taken 661786 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 661786 times.
✗ Branch 3 not taken.
661796 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
18213
3/4
✓ Branch 0 taken 661786 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 661786 times.
✗ Branch 3 not taken.
661796 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
18214
3/4
✓ Branch 0 taken 661786 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 661786 times.
✗ Branch 3 not taken.
661796 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
18215
1/2
✓ Branch 0 taken 661776 times.
✗ Branch 1 not taken.
661786 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
18216 {
18217 1 changecombo=true;
18218 1 doit=true;
18219 1 }
18220
18221
2/2
✓ Branch 0 taken 162314 times.
✓ Branch 1 taken 499472 times.
661786 if(get_bit(quest_rules,qr_SOLIDBLK))
18222 {
18223
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
✓ Branch 2 taken 25999 times.
✓ Branch 3 taken 48784 times.
✓ Branch 4 taken 57835 times.
162314 switch(dir)
18224 {
18225 case up:
18226
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 29696 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29696 times.
✓ Branch 4 taken 14113 times.
✓ Branch 5 taken 15583 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15583 times.
✓ Branch 8 taken 14117 times.
✓ Branch 9 taken 15579 times.
29696 if(_walkflag(bx,by-8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)) doit=false;
18227
18228 29696 break;
18229
18230 case down:
18231
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 25999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25999 times.
✓ Branch 4 taken 9717 times.
✓ Branch 5 taken 16282 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 16282 times.
✓ Branch 8 taken 9721 times.
✓ Branch 9 taken 16278 times.
25999 if(_walkflag(bx,by+24,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)) doit=false;
18232
18233 25999 break;
18234
18235 case left:
18236
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 48784 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 48784 times.
✓ Branch 4 taken 18402 times.
✓ Branch 5 taken 30382 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 30382 times.
✓ Branch 8 taken 18408 times.
✓ Branch 9 taken 30376 times.
48784 if(_walkflag(bx-16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)) doit=false;
18237
18238 48784 break;
18239
18240 case right:
18241
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 57835 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57835 times.
✓ Branch 4 taken 19909 times.
✓ Branch 5 taken 37926 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 37926 times.
✓ Branch 8 taken 19919 times.
✓ Branch 9 taken 37916 times.
57835 if(_walkflag(bx+16,by+8,2,SWITCHBLOCK_STATE)&&!(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)) doit=false;
18242
18243 57835 break;
18244 }
18245 162314 }
18246
18247
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 238366 times.
✓ Branch 2 taken 203450 times.
✓ Branch 3 taken 105781 times.
✓ Branch 4 taken 114189 times.
661786 switch(dir)
18248 {
18249 case up:
18250
3/4
✓ Branch 0 taken 238034 times.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 238034 times.
238366 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
18251
18252 238366 break;
18253
18254 case down:
18255
3/4
✓ Branch 0 taken 203034 times.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 203034 times.
203450 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
18256
18257 203450 break;
18258
18259 case left:
18260
3/4
✓ Branch 0 taken 105699 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105699 times.
105781 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
18261
18262 105781 break;
18263
18264 case right:
18265
3/4
✓ Branch 0 taken 114165 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114165 times.
114189 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
18266
18267 114189 break;
18268 }
18269
18270
2/2
✓ Branch 0 taken 661060 times.
✓ Branch 1 taken 726 times.
661786 if(doit)
18271 {
18272
2/2
✓ Branch 0 taken 719 times.
✓ Branch 1 taken 7 times.
726 if(limitedpush)
18273 7 ++usecounts[itemid];
18274
18275 // for(int32_t i=0; i<1; i++)
18276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 726 times.
726 if(!blockmoving)
18277 {
18278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 726 times.
726 if(changeflag)
18279 {
18280 726 m->sflag[combopos]=0;
18281 726 }
18282
18283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 726 times.
726 if(mblock2.clk<=0)
18284 {
18285 726 mblock2.blockLayer = lyr;
18286 726 mblock2.push((zfix)bx,(zfix)by,dir,f);
18287
18288
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 724 times.
726 if(get_bit(quest_rules,qr_MORESOUNDS))
18289 2 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
18290 726 }
18291 726 }
18292 726 break;
18293 }
18294 661060 }
18295 6431495 }
18296
18297 180 bool usekey()
18298 {
18299 180 int32_t itemid = current_item_id(itype_magickey);
18300
18301
3/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
180 if(itemid<0 ||
18302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18303 : itemsbuf[itemid].power!=dlevel))
18304 {
18305
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 115 times.
150 if(game->lvlkeys[dlevel]!=0)
18306 {
18307 35 game->lvlkeys[dlevel]--;
18308 //run script for level key item
18309 35 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
18310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2975 times.
2975 for ( int32_t q = 0; q < MAXITEMS; ++q )
18311 {
18312
2/2
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 35 times.
2975 if ( itemsbuf[q].family == itype_lkey )
18313 {
18314 35 key_item = q; break;
18315 }
18316 2940 }
18317
18318
2/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18319 {
18320 ri = &(itemScriptData[key_item]);
18321 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18322 ri->Clear();
18323 item_doscript[key_item] = 1;
18324 itemscriptInitialised[key_item] = 0;
18325 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18326 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18327 }
18328 35 return true;
18329 }
18330 else
18331 {
18332
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 81 times.
115 if(game->get_keys()==0)
18333 {
18334 34 return false;
18335 }
18336 else
18337 {
18338 //run script for key item
18339 81 int32_t key_item = 0; //current_item_id(itype_key); //not possible
18340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 810 times.
810 for ( int32_t q = 0; q < MAXITEMS; ++q )
18341 {
18342
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 81 times.
810 if ( itemsbuf[q].family == itype_key )
18343 {
18344 81 key_item = q; break;
18345 }
18346 729 }
18347 //zprint2("key_item is: %d\n",key_item);
18348 //zprint2("key_item script is: %d\n",itemsbuf[key_item].script);
18349
2/8
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
81 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18350 {
18351 ri = &(itemScriptData[key_item]);
18352 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18353 ri->Clear();
18354 item_doscript[key_item] = 1;
18355 itemscriptInitialised[key_item] = 0;
18356 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18357 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18358 }
18359 81 game->change_keys(-1);
18360 }
18361 }
18362 81 }
18363
18364 111 return true;
18365 180 }
18366
18367 bool canUseKey(int32_t num)
18368 {
18369 int32_t itemid = current_item_id(itype_magickey);
18370
18371 if(itemid<0 ||
18372 (itemsbuf[itemid].flags & ITEM_FLAG1 ? itemsbuf[itemid].power<dlevel
18373 : itemsbuf[itemid].power!=dlevel))
18374 {
18375 return game->lvlkeys[dlevel] + game->get_keys() >= num;
18376 }
18377
18378 return true;
18379 }
18380
18381 bool usekey(int32_t num)
18382 {
18383 if(!canUseKey(num)) return false;
18384 for(auto q = 0; q < num; ++q)
18385 {
18386 if(!usekey()) return false; //should never return false here, but, just to be safe....
18387 }
18388 return true;
18389 }
18390
18391
18392 454 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
18393 {
18394 454 int32_t mc = (y&0xF0)+(x>>4);
18395
3/6
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
908 bool ret = (((mc==7||mc==8||mc==23||mc==24) && tmpscr->door[up]==lock)
18396
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 454 times.
✗ Branch 7 not taken.
454 || ((mc==151||mc==152||mc==167||mc==168) && tmpscr->door[down]==lock)
18397
3/6
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
454 || ((mc==64||mc==65||mc==80||mc==81) && tmpscr->door[left]==lock)
18398
4/8
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 454 times.
454 || ((mc==78||mc==79||mc==94||mc==95) && tmpscr->door[right]==lock));
18399 454 return ret;
18400 }
18401
18402 5120205 void HeroClass::oldchecklockblock()
18403 {
18404
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 5106799 times.
5120205 if(toogam) return;
18405
18406 5106799 int32_t bx = x.getInt()&0xF0;
18407 5106799 int32_t bx2 = int32_t(x+8)&0xF0;
18408 5106799 int32_t by = y.getInt()&0xF0;
18409
18410
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1195247 times.
✓ Branch 2 taken 956788 times.
✓ Branch 3 taken 1418666 times.
✓ Branch 4 taken 1536098 times.
5106799 switch(dir)
18411 {
18412 case up:
18413
4/4
✓ Branch 0 taken 214057 times.
✓ Branch 1 taken 981190 times.
✓ Branch 2 taken 4741 times.
✓ Branch 3 taken 209316 times.
1195247 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18414
18415 1195247 break;
18416
18417 case down:
18418 956788 by+=16;
18419 956788 break;
18420
18421 case left:
18422
2/2
✓ Branch 0 taken 624089 times.
✓ Branch 1 taken 794577 times.
1418666 if((((int32_t)x)&0x0F)<8)
18423 794577 bx-=16;
18424
18425
2/2
✓ Branch 0 taken 907044 times.
✓ Branch 1 taken 511622 times.
1418666 if(y.getInt()&8)
18426 {
18427 511622 by+=16;
18428 511622 }
18429
18430 1418666 bx2=bx;
18431 1418666 break;
18432
18433 case right:
18434 1536098 bx+=16;
18435
18436
2/2
✓ Branch 0 taken 1003284 times.
✓ Branch 1 taken 532814 times.
1536098 if(y.getInt()&8)
18437 {
18438 532814 by+=16;
18439 532814 }
18440
18441 1536098 bx2=bx;
18442 1536098 break;
18443 }
18444
18445 5106799 bool found1=false;
18446 5106799 bool found2=false;
18447 5106799 int32_t foundlayer = -1;
18448 5106799 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18449 5106799 newcombo const& cmb = combobuf[cid1];
18450 5106799 newcombo const& cmb2 = combobuf[cid2];
18451 // Layer 0 is overridden by Locked Doors
18452
5/8
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 5106419 times.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 380 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 380 times.
5106799 if((cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1) && !islockeddoor(bx,by,dLOCKED)))
18453 {
18454 380 found1=true;
18455 380 foundlayer = 0;
18456 380 }
18457
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 5106419 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5106419 else if (cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, -1) && !islockeddoor(bx2,by,dLOCKED))
18458 {
18459 found2=true;
18460 foundlayer = 0;
18461 }
18462
18463
2/2
✓ Branch 0 taken 10213598 times.
✓ Branch 1 taken 5106799 times.
15320397 for (int32_t i = 0; i <= 1; ++i)
18464 {
18465
2/2
✓ Branch 0 taken 8560889 times.
✓ Branch 1 taken 1652709 times.
10213598 if(tmpscr2[i].valid!=0)
18466 {
18467
2/2
✓ Branch 0 taken 1544854 times.
✓ Branch 1 taken 107855 times.
1652709 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18468 {
18469
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1544854 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1544854 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18470
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1544854 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1544854 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18471 1544854 }
18472 else
18473 {
18474
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found1 = false;
18475
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found2 = false;
18476 }
18477 1652709 }
18478 10213598 }
18479
18480
18481 // Layers
18482
3/4
✓ Branch 0 taken 5106419 times.
✓ Branch 1 taken 380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5106419 times.
5106799 if(!(found1 || found2))
18483 {
18484 5106419 foundlayer = -1;
18485
2/2
✓ Branch 0 taken 5106385 times.
✓ Branch 1 taken 10212804 times.
15319189 for(int32_t i=0; i<2; i++)
18486 {
18487 10212804 cid1 = MAPCOMBO2(i, bx, by);
18488 10212804 cid2 = MAPCOMBO2(i, bx2, by);
18489 10212804 newcombo const& cmb = combobuf[cid1];
18490 10212804 newcombo const& cmb2 = combobuf[cid2];
18491
2/2
✓ Branch 0 taken 5106385 times.
✓ Branch 1 taken 5106419 times.
10212804 if (i == 0)
18492 {
18493
2/2
✓ Branch 0 taken 4842453 times.
✓ Branch 1 taken 263966 times.
5106419 if(tmpscr2[1].valid!=0)
18494 {
18495
2/2
✓ Branch 0 taken 219412 times.
✓ Branch 1 taken 44554 times.
263966 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18496 {
18497
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219412 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219412 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue; //Continue, because It didn't find any on layer 0, and if you're checking
18498
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219412 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219412 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
18499 219412 }
18500 else
18501 {
18502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44554 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18504 }
18505 263966 }
18506 5106419 }
18507
4/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 10212770 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
10212804 if(cmb.type==cLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18508 {
18509 34 found1=true;
18510 34 foundlayer = i+1;
18511 //zprint("Found layer: %d \n", i);
18512 34 break;
18513 }
18514
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10212770 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10212770 else if(cmb2.type==cLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by,1, i))
18515 {
18516 found2=true;
18517 foundlayer = i+1;
18518 //zprint("Found layer: %d \n", i);
18519 break;
18520 }
18521 10212770 }
18522 5106419 }
18523
18524
4/4
✓ Branch 0 taken 5106385 times.
✓ Branch 1 taken 414 times.
✓ Branch 2 taken 5106763 times.
✓ Branch 3 taken 36 times.
5106799 if(!(found1 || found2) || pushing<8)
18525 {
18526 5106763 return;
18527 }
18528
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
18529
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 25 times.
36 if(!try_locked_combo(cmb3))
18530 25 return;
18531
18532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(cmb.usrflags&cflag16)
18533 {
18534 setxmapflag(1<<cmb.attribytes[5]);
18535 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18536 }
18537 else
18538 {
18539 11 setmapflag(mLOCKBLOCK);
18540 11 remove_lockblocks((currscr>=128)?1:0);
18541 }
18542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( cmb3.usrflags&cflag3 )
18543 {
18544 if ( (cmb3.attribytes[3]) )
18545 sfx(cmb3.attribytes[3]);
18546 }
18547 11 else sfx(WAV_DOOR);
18548 5120205 }
18549
18550 5120205 void HeroClass::oldcheckbosslockblock()
18551 {
18552
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 5106799 times.
5120205 if(toogam) return;
18553
18554 5106799 int32_t bx = x.getInt()&0xF0;
18555 5106799 int32_t bx2 = int32_t(x+8)&0xF0;
18556 5106799 int32_t by = y.getInt()&0xF0;
18557
18558
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1195247 times.
✓ Branch 2 taken 956788 times.
✓ Branch 3 taken 1418666 times.
✓ Branch 4 taken 1536098 times.
5106799 switch(dir)
18559 {
18560 case up:
18561
4/4
✓ Branch 0 taken 214057 times.
✓ Branch 1 taken 981190 times.
✓ Branch 2 taken 4741 times.
✓ Branch 3 taken 209316 times.
1195247 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18562
18563 1195247 break;
18564
18565 case down:
18566 956788 by+=16;
18567 956788 break;
18568
18569 case left:
18570
2/2
✓ Branch 0 taken 624089 times.
✓ Branch 1 taken 794577 times.
1418666 if((((int32_t)x)&0x0F)<8)
18571 794577 bx-=16;
18572
18573
2/2
✓ Branch 0 taken 907044 times.
✓ Branch 1 taken 511622 times.
1418666 if(y.getInt()&8)
18574 {
18575 511622 by+=16;
18576 511622 }
18577
18578 1418666 bx2=bx;
18579 1418666 break;
18580
18581 case right:
18582 1536098 bx+=16;
18583
18584
2/2
✓ Branch 0 taken 1003284 times.
✓ Branch 1 taken 532814 times.
1536098 if(y.getInt()&8)
18585 {
18586 532814 by+=16;
18587 532814 }
18588
18589 1536098 bx2=bx;
18590 1536098 break;
18591 }
18592
18593
18594 5106799 bool found1 = false;
18595 5106799 bool found2 = false;
18596 5106799 int32_t foundlayer = -1;
18597 5106799 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
18598 5106799 newcombo const& cmb = combobuf[cid1];
18599 5106799 newcombo const& cmb2 = combobuf[cid2];
18600 // Layer 0 is overridden by Locked Doors
18601
5/8
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 5106725 times.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 74 times.
5106799 if ((cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, -1) && !islockeddoor(bx, by, dLOCKED)))
18602 {
18603 74 found1 = true;
18604 74 foundlayer = 0;
18605 74 }
18606
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 5106725 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5106725 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, -1) && !islockeddoor(bx2, by, dLOCKED))
18607 {
18608 found2 = true;
18609 foundlayer = 0;
18610 }
18611
18612
2/2
✓ Branch 0 taken 10213598 times.
✓ Branch 1 taken 5106799 times.
15320397 for (int32_t i = 0; i <= 1; ++i)
18613 {
18614
2/2
✓ Branch 0 taken 8560889 times.
✓ Branch 1 taken 1652709 times.
10213598 if (tmpscr2[i].valid != 0)
18615 {
18616
2/2
✓ Branch 0 taken 1544854 times.
✓ Branch 1 taken 107855 times.
1652709 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18617 {
18618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1544854 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1544854 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18619
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1544854 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1544854 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18620 1544854 }
18621 else
18622 {
18623
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[i]))) found1 = false;
18624
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 107823 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
107855 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[i]))) found2 = false;
18625 }
18626 1652709 }
18627 10213598 }
18628
18629
18630 // Layers
18631
3/4
✓ Branch 0 taken 5106725 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5106725 times.
5106799 if (!(found1 || found2))
18632 {
18633 5106725 foundlayer = -1;
18634
2/2
✓ Branch 0 taken 5106725 times.
✓ Branch 1 taken 10213450 times.
15320175 for (int32_t i = 0; i < 2; i++)
18635 {
18636 10213450 cid1 = MAPCOMBO2(i, bx, by);
18637 10213450 cid2 = MAPCOMBO2(i, bx2, by);
18638 10213450 newcombo const& cmb = combobuf[cid1];
18639 10213450 newcombo const& cmb2 = combobuf[cid2];
18640
2/2
✓ Branch 0 taken 5106725 times.
✓ Branch 1 taken 5106725 times.
10213450 if (i == 0)
18641 {
18642
2/2
✓ Branch 0 taken 4842667 times.
✓ Branch 1 taken 264058 times.
5106725 if (tmpscr2[1].valid != 0)
18643 {
18644
2/2
✓ Branch 0 taken 219440 times.
✓ Branch 1 taken 44618 times.
264058 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18645 {
18646
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219440 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 219440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
219440 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18648 219440 }
18649 else
18650 {
18651
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by, 1, &(tmpscr2[1]))) continue;
18652
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44618 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by, 1, &(tmpscr2[1]))) continue;
18653 }
18654 264058 }
18655 5106725 }
18656
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10213450 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10213450 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx, by, 1, i))
18657 {
18658 found1 = true;
18659 foundlayer = i;
18660 break;
18661 }
18662
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10213450 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10213450 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2, by, 1, i))
18663 {
18664 found2 = true;
18665 foundlayer = i;
18666 break;
18667 }
18668 10213450 }
18669 5106725 }
18670
18671
4/4
✓ Branch 0 taken 5106725 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 5106779 times.
✓ Branch 3 taken 20 times.
5106799 if (!(found1 || found2) || pushing < 8)
18672 {
18673 5106779 return;
18674 }
18675
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 int32_t cid = found1 ? cid1 : cid2;
18676
18677
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 17 times.
20 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18678
18679
18680 // Run Boss Key Script
18681 3 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
204 for ( int32_t q = 0; q < MAXITEMS; ++q )
18683 {
18684
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 3 times.
204 if ( itemsbuf[q].family == itype_bosskey )
18685 {
18686 3 key_item = q; break;
18687 }
18688 201 }
18689
2/8
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18690 {
18691 ri = &(itemScriptData[key_item]);
18692 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18693 ri->Clear();
18694 item_doscript[key_item] = 1;
18695 itemscriptInitialised[key_item] = 0;
18696 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18697 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18698 }
18699
18700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(cmb.usrflags&cflag16)
18701 {
18702 setxmapflag(1<<cmb.attribytes[5]);
18703 remove_xstatecombos((currscr>=128)?1:0, 1<<cmb.attribytes[5]);
18704 }
18705 else
18706 {
18707 3 setmapflag(mBOSSLOCKBLOCK);
18708 3 remove_bosslockblocks((currscr>=128)?1:0);
18709 }
18710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (combobuf[cid].attribytes[3]) )
18711 3 sfx(combobuf[cid].attribytes[3]);
18712 5120205 }
18713
18714 14971614 void HeroClass::oldcheckchest(int32_t type)
18715 {
18716 // chests aren't affected by tmpscr->flags2&fAIRCOMBOS
18717
5/6
✓ Branch 0 taken 14931396 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 14922339 times.
✓ Branch 3 taken 9057 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14922339 times.
14971614 if(toogam || z>0 || fakez > 0) return;
18718
2/2
✓ Branch 0 taken 14251452 times.
✓ Branch 1 taken 670887 times.
14922339 if(pushing<8) return;
18719 670887 int32_t bx = x.getInt()&0xF0;
18720 670887 int32_t bx2 = int32_t(x+8)&0xF0;
18721 670887 int32_t by = y.getInt()&0xF0;
18722
18723
3/4
✓ Branch 0 taken 370428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133473 times.
✓ Branch 3 taken 166986 times.
670887 switch(dir)
18724 {
18725 case up:
18726
2/2
✓ Branch 0 taken 40752 times.
✓ Branch 1 taken 126234 times.
166986 if(isSideViewHero()) return;
18727
18728
4/4
✓ Branch 0 taken 37554 times.
✓ Branch 1 taken 88680 times.
✓ Branch 2 taken 36576 times.
✓ Branch 3 taken 978 times.
126234 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
18729
18730 126234 break;
18731
18732 case left:
18733 case right:
18734
2/2
✓ Branch 0 taken 16173 times.
✓ Branch 1 taken 354255 times.
370428 if(isSideViewHero()) break;
18735 [[fallthrough]];
18736 case down:
18737 487728 return;
18738 }
18739
18740 142407 bool found=false;
18741 142407 bool itemflag=false;
18742
18743
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 142399 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
142407 if((combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))||
18744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142399 times.
142399 (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1)))
18745 {
18746 8 found=true;
18747 8 }
18748
2/2
✓ Branch 0 taken 284814 times.
✓ Branch 1 taken 142407 times.
427221 for (int32_t i = 0; i <= 1; ++i)
18749 {
18750
2/2
✓ Branch 0 taken 240783 times.
✓ Branch 1 taken 44031 times.
284814 if(tmpscr2[i].valid!=0)
18751 {
18752
2/2
✓ Branch 0 taken 43170 times.
✓ Branch 1 taken 861 times.
44031 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18753 {
18754
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43170 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43170 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18755
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 43170 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
43170 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18756 43170 }
18757 else
18758 {
18759
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = false;
18760
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
861 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[i]))) found = false;
18761 }
18762 44031 }
18763 284814 }
18764
18765
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 142399 times.
142407 if(!found)
18766 {
18767
2/2
✓ Branch 0 taken 142399 times.
✓ Branch 1 taken 284798 times.
427197 for(int32_t i=0; i<2; i++)
18768 {
18769
2/2
✓ Branch 0 taken 142399 times.
✓ Branch 1 taken 142399 times.
284798 if (i == 0)
18770 {
18771
2/2
✓ Branch 0 taken 137128 times.
✓ Branch 1 taken 5271 times.
142399 if(tmpscr2[1].valid!=0)
18772 {
18773
2/2
✓ Branch 0 taken 4890 times.
✓ Branch 1 taken 381 times.
5271 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18774 {
18775
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4890 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4890 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18776
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4890 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4890 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18777 4890 }
18778 else
18779 {
18780
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) continue;
18781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
381 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1, &(tmpscr2[1]))) continue;
18782 }
18783 5271 }
18784 142399 }
18785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 284798 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
284798 if((combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))||
18786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 284798 times.
284798 (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i)))
18787 {
18788 found=true;
18789 break;
18790 }
18791 284798 }
18792 142399 }
18793
18794
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 142399 times.
142407 if(!found)
18795 {
18796 142399 return;
18797 }
18798
18799
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 switch(type)
18800 {
18801 case cLOCKEDCHEST:
18802 if(!usekey()) return;
18803
18804 setmapflag(mLOCKEDCHEST);
18805 break;
18806
18807 case cCHEST:
18808 8 setmapflag(mCHEST);
18809 8 break;
18810
18811 case cBOSSCHEST:
18812 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
18813 // Run Boss Key Script
18814 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
18815 for ( int32_t q = 0; q < MAXITEMS; ++q )
18816 {
18817 if ( itemsbuf[q].family == itype_bosskey )
18818 {
18819 key_item = q; break;
18820 }
18821 }
18822 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
18823 {
18824 ri = &(itemScriptData[key_item]);
18825 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
18826 ri->Clear();
18827 item_doscript[key_item] = 1;
18828 itemscriptInitialised[key_item] = 0;
18829 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
18830 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
18831 }
18832 setmapflag(mBOSSCHEST);
18833 break;
18834 }
18835
18836 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18837 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18838 8 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
18839 8 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
18840 8 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
18841 8 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
18842
18843
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(!itemflag)
18844 {
18845 for(int32_t i=0; i<2; i++)
18846 {
18847 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
18848 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
18849 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
18850 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
18851 }
18852 }
18853
18854
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
8 if(itemflag && !getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
18855 {
18856
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
8 items.add(new item(x, y,(zfix)0, tmpscr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
18857 8 }
18858 14971614 }
18859
18860 517045 void HeroClass::checkchest(int32_t type)
18861 {
18862
4/4
✓ Branch 0 taken 361772 times.
✓ Branch 1 taken 155273 times.
✓ Branch 2 taken 155273 times.
✓ Branch 3 taken 206499 times.
517045 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
18863
2/2
✓ Branch 0 taken 25613 times.
✓ Branch 1 taken 491432 times.
517045 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
18864
2/2
✓ Branch 0 taken 25613 times.
✓ Branch 1 taken 491432 times.
517045 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
18865
2/2
✓ Branch 0 taken 25613 times.
✓ Branch 1 taken 491432 times.
517045 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
18866
2/2
✓ Branch 0 taken 51226 times.
✓ Branch 1 taken 465819 times.
517045 if(ischest)
18867 {
18868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 465819 times.
465819 if(get_bit(quest_rules,qr_OLD_CHEST_COLLISION))
18869 {
18870 oldcheckchest(type);
18871 return;
18872 }
18873 465819 }
18874
3/4
✓ Branch 0 taken 51226 times.
✓ Branch 1 taken 465819 times.
✓ Branch 2 taken 51226 times.
✗ Branch 3 not taken.
517045 if(islockblock && get_bit(quest_rules, qr_OLD_LOCKBLOCK_COLLISION))
18875 {
18876 if(type == cLOCKBLOCK)
18877 oldchecklockblock();
18878 else if(type == cBOSSLOCKBLOCK)
18879 oldcheckbosslockblock();
18880 return;
18881 }
18882
4/6
✓ Branch 0 taken 517045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 516289 times.
✓ Branch 3 taken 756 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 516289 times.
517045 if(toogam || z>0 || fakez > 0) return;
18883 516289 zfix bx, by;
18884 516289 zfix bx2, by2;
18885 516289 zfix fx(-1), fy(-1);
18886
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 108108 times.
✓ Branch 2 taken 117064 times.
✓ Branch 3 taken 134324 times.
✓ Branch 4 taken 156793 times.
516289 switch(dir)
18887 {
18888 case up:
18889 108108 by = y + (bigHitbox ? -2 : 6);
18890 108108 by2 = by;
18891 108108 bx = x + 4;
18892 108108 bx2 = bx + 8;
18893 108108 break;
18894 case down:
18895 117064 by = y + 17;
18896 117064 by2 = by;
18897 117064 bx = x + 4;
18898 117064 bx2 = bx + 8;
18899 117064 break;
18900 case left:
18901 134324 by = y + (bigHitbox ? 0 : 8);
18902 134324 by2 = y + 8;
18903 134324 bx = x - 2;
18904 134324 bx2 = x - 2;
18905 134324 break;
18906 case right:
18907 156793 by = y + (bigHitbox ? 0 : 8);
18908 156793 by2 = y + 8;
18909 156793 bx = x + 17;
18910 156793 bx2 = x + 17;
18911 156793 break;
18912 }
18913
18914 516289 int32_t found = -1;
18915 516289 int32_t foundlayer = 0;
18916
18917 516289 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
18918
18919
4/6
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 515418 times.
✓ Branch 2 taken 871 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 871 times.
516289 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, -1))
18920 {
18921 871 found = MAPCOMBO(bx,by);
18922 871 fx = bx; fy = by;
18923
2/2
✓ Branch 0 taken 1742 times.
✓ Branch 1 taken 871 times.
2613 for (int32_t i = 0; i <= 1; ++i)
18924 {
18925
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 1357 times.
1742 if(tmpscr2[i].valid!=0)
18926 {
18927
1/2
✓ Branch 0 taken 1357 times.
✗ Branch 1 not taken.
1357 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18928 {
18929
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1357 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1357 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18930 1357 }
18931 else
18932 {
18933 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
18934 }
18935 1357 }
18936 1742 }
18937 871 }
18938
2/2
✓ Branch 0 taken 871 times.
✓ Branch 1 taken 515418 times.
516289 if(found<0)
18939 {
18940 515418 cmb = &combobuf[MAPCOMBO(bx2,by2)];
18941
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 515395 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
515418 if(cmb->type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, -1))
18942 {
18943 23 found = MAPCOMBO(bx2,by2);
18944
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 161 times.
184 for (int32_t i = 0; i <= 6; ++i)
18945 {
18946
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 46 times.
161 if(tmpscr2[i].valid!=0)
18947 {
18948
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18949 {
18950
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i])))
18951 {
18952 found = -1;
18953 break;
18954 }
18955 46 }
18956 else
18957 {
18958 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i])))
18959 {
18960 found = -1;
18961 break;
18962 }
18963 }
18964 46 }
18965 161 }
18966
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(found != -1)
18967 {
18968 23 fx = bx2; fy = by2;
18969 23 }
18970 23 }
18971 515418 }
18972
18973
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 515395 times.
516289 if(found<0)
18974 {
18975
2/2
✓ Branch 0 taken 515342 times.
✓ Branch 1 taken 3092105 times.
3607447 for(int32_t i=0; i<6; i++)
18976 {
18977 3092105 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
18978
4/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 3092052 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 53 times.
3092105 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx,by,1, i))
18979 {
18980 53 found = MAPCOMBO2(i,bx,by);
18981
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 265 times.
318 for(int32_t j = i+1; j < 6; ++j)
18982 {
18983
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 53 times.
265 if (tmpscr2[j].valid!=0)
18984 {
18985
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
18986 {
18987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[j])))
18988 {
18989 found = -1;
18990 break;
18991 }
18992 53 }
18993 else
18994 {
18995 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[j])))
18996 {
18997 found = -1;
18998 break;
18999 }
19000 }
19001 53 }
19002 265 }
19003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(found>-1)
19004 {
19005 53 foundlayer = i+1;
19006 53 fx = bx; fy = by;
19007 53 break;
19008 }
19009 }
19010 3092052 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
19011
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3092052 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3092052 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->triggerflags[0] & combotriggerONLYGENTRIG) && _effectflag(bx2,by2,1, i))
19012 {
19013 found = MAPCOMBO2(i,bx2,by2);
19014 for(int32_t j = i+1; j < 6; ++j)
19015 {
19016 if (tmpscr2[j].valid!=0)
19017 {
19018 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19019 {
19020 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[j])))
19021 {
19022 found = -1;
19023 break;
19024 }
19025 }
19026 else
19027 {
19028 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[j])))
19029 {
19030 found = -1;
19031 break;
19032 }
19033 }
19034 }
19035 }
19036 if(found>-1)
19037 {
19038 foundlayer = i+1;
19039 fx = bx2; fy = by2;
19040 break;
19041 }
19042 }
19043 3092052 }
19044 515395 }
19045
19046
2/2
✓ Branch 0 taken 947 times.
✓ Branch 1 taken 515342 times.
516289 if(found<0) return;
19047 947 cmb = &combobuf[found];
19048
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
947 switch(dir)
19049 {
19050 case up:
19051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags&cflag10)
19052 return;
19053 947 break;
19054 case down:
19055 if(cmb->usrflags&cflag9)
19056 return;
19057 break;
19058 case left:
19059 if(cmb->usrflags&cflag12)
19060 return;
19061 break;
19062 case right:
19063 if(cmb->usrflags&cflag11)
19064 return;
19065 break;
19066 }
19067 947 int32_t intbtn = cmb->attribytes[2];
19068
19069
1/2
✓ Branch 0 taken 947 times.
✗ Branch 1 not taken.
947 if(intbtn) //
19070 {
19071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
947 if(cmb->usrflags & cflag13) //display prompt
19072 {
19073 947 int altcmb = cmb->attributes[2]/10000;
19074 947 prompt_combo = cmb->attributes[1]/10000;
19075
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
947 if(altcmb && ((islocked && !can_locked_combo(*cmb))
19076 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
19077 prompt_combo = altcmb;
19078 947 prompt_cset = cmb->attribytes[4];
19079 947 prompt_x = cmb->attrishorts[0];
19080 947 prompt_y = cmb->attrishorts[1];
19081 947 }
19082
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 935 times.
947 if(!getIntBtnInput(intbtn, true, true, false, false))
19083 {
19084 935 return; //Button not pressed
19085 }
19086 12 }
19087 else if(pushing < 8) return; //Not pushing against chest enough
19088
19089
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(ischest)
19090 {
19091
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!trigger_chest(foundlayer, COMBOPOS(fx,fy))) return;
19092 12 }
19093 else if(islockblock)
19094 {
19095 if(!trigger_lockblock(foundlayer, COMBOPOS(fx,fy))) return;
19096 }
19097
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(intbtn && (cmb->usrflags & cflag13))
19098 12 prompt_combo = 0;
19099 517045 }
19100
19101 5152513 void HeroClass::checkgenpush()
19102 {
19103
4/4
✓ Branch 0 taken 229477 times.
✓ Branch 1 taken 4923036 times.
✓ Branch 2 taken 195773 times.
✓ Branch 3 taken 33704 times.
5152513 if(pushing < 8 || pushing % 8) return;
19104 33704 zfix bx, by;
19105 33704 zfix bx2, by2;
19106
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8395 times.
✓ Branch 2 taken 7002 times.
✓ Branch 3 taken 8864 times.
✓ Branch 4 taken 9443 times.
33704 switch(dir)
19107 {
19108 case up:
19109 8395 by = y + (bigHitbox ? -2 : 6);
19110 8395 by2 = by;
19111 8395 bx = x + 4;
19112 8395 bx2 = bx + 8;
19113 8395 break;
19114 case down:
19115 7002 by = y + 17;
19116 7002 by2 = by;
19117 7002 bx = x + 4;
19118 7002 bx2 = bx + 8;
19119 7002 break;
19120 case left:
19121 8864 by = y + (bigHitbox ? 0 : 8);
19122 8864 by2 = y + 8;
19123 8864 bx = x - 2;
19124 8864 bx2 = x - 2;
19125 8864 break;
19126 case right:
19127 9443 by = y + (bigHitbox ? 0 : 8);
19128 9443 by2 = y + 8;
19129 9443 bx = x + 17;
19130 9443 bx2 = x + 17;
19131 9443 break;
19132 }
19133 33704 auto pos1 = COMBOPOS(bx,by);
19134 33704 auto pos2 = COMBOPOS(bx2,by2);
19135
2/2
✓ Branch 0 taken 33704 times.
✓ Branch 1 taken 235928 times.
269632 for(auto layer = 0; layer < 7; ++layer)
19136 {
19137 235928 mapscr* tmp = FFCore.tempScreens[layer];
19138
19139 235928 newcombo const& cmb1 = combobuf[tmp->data[pos1]];
19140
2/2
✓ Branch 0 taken 235927 times.
✓ Branch 1 taken 1 times.
235928 if(cmb1.triggerflags[1] & combotriggerPUSH)
19141 1 do_trigger_combo(layer,pos1);
19142
19143
2/2
✓ Branch 0 taken 197183 times.
✓ Branch 1 taken 38745 times.
235928 if(pos1==pos2) continue;
19144
19145 38745 newcombo const& cmb2 = combobuf[tmp->data[pos2]];
19146
1/2
✓ Branch 0 taken 38745 times.
✗ Branch 1 not taken.
38745 if(cmb2.triggerflags[1] & combotriggerPUSH)
19147 do_trigger_combo(layer,pos2);
19148 38745 }
19149
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 32752 times.
33704 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
19150 {
19151 952 word c = tmpscr->numFFC();
19152
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 6048 times.
7000 for(word i=0; i<c; i++)
19153 {
19154
4/4
✓ Branch 0 taken 5889 times.
✓ Branch 1 taken 159 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 5873 times.
6048 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
19155 {
19156 175 ffcdata& ffc = tmpscr->ffcs[i];
19157 175 newcombo const& cmb3 = combobuf[ffc.getData()];
19158
1/2
✓ Branch 0 taken 175 times.
✗ Branch 1 not taken.
175 if(cmb3.triggerflags[1] & combotriggerPUSH)
19159 {
19160 do_trigger_combo_ffc(i);
19161 break;
19162 }
19163 175 }
19164 6048 }
19165 952 }
19166 5152513 }
19167
19168 5152514 void HeroClass::checksigns() //Also checks for generic trigger buttons
19169 {
19170
5/6
✓ Branch 0 taken 5139108 times.
✓ Branch 1 taken 13406 times.
✓ Branch 2 taken 5135831 times.
✓ Branch 3 taken 3277 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5135831 times.
5152514 if(toogam || z>0 || fakez>0) return;
19171
5/6
✓ Branch 0 taken 5110642 times.
✓ Branch 1 taken 25189 times.
✓ Branch 2 taken 71347 times.
✓ Branch 3 taken 5039295 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 71347 times.
5135831 if(msg_active || (msg_onscreen && get_bit(quest_rules, qr_MSGDISAPPEAR)))
19172 25189 return; //Don't overwrite a message waiting to be dismissed
19173 5110642 zfix bx, by;
19174 5110642 zfix bx2, by2;
19175 5110642 zfix fx(-1), fy(-1);
19176
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1177637 times.
✓ Branch 2 taken 961978 times.
✓ Branch 3 taken 1421760 times.
✓ Branch 4 taken 1549267 times.
5110642 switch(dir)
19177 {
19178 case up:
19179 1177637 by = y + (bigHitbox ? -2 : 6);
19180 1177637 by2 = by;
19181 1177637 bx = x + 4;
19182 1177637 bx2 = bx + 8;
19183 1177637 break;
19184 case down:
19185 961978 by = y + 17;
19186 961978 by2 = by;
19187 961978 bx = x + 4;
19188 961978 bx2 = bx + 8;
19189 961978 break;
19190 case left:
19191 1421760 by = y + (bigHitbox ? 0 : 8);
19192 1421760 by2 = y + 8;
19193 1421760 bx = x - 2;
19194 1421760 bx2 = x - 2;
19195 1421760 break;
19196 case right:
19197 1549267 by = y + (bigHitbox ? 0 : 8);
19198 1549267 by2 = y + 8;
19199 1549267 bx = x + 17;
19200 1549267 bx2 = x + 17;
19201 1549267 break;
19202 }
19203
19204 5110642 int32_t found = -1;
19205 5110642 int32_t foundffc = -1;
19206 5110642 int32_t found_lyr = 0;
19207 5110642 bool found_sign = false;
19208 5110642 int32_t tmp_cid = MAPCOMBO(bx,by);
19209 5110642 newcombo const* tmp_cmb = &combobuf[tmp_cid];
19210
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5110642 times.
✓ Branch 2 taken 5109996 times.
✓ Branch 3 taken 646 times.
10221284 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19211 5110642 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, -1))
19212 {
19213 646 found = tmp_cid;
19214 646 fx = bx; fy = by;
19215
2/2
✓ Branch 0 taken 1292 times.
✓ Branch 1 taken 646 times.
1938 for (int32_t i = 0; i <= 1; ++i)
19216 {
19217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if(tmpscr2[i].valid!=0)
19218 {
19219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
1292 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19220 {
19221 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19222 }
19223 else
19224 {
19225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1292 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[i]))) found = -1;
19226 }
19227 1292 }
19228 1292 }
19229 646 }
19230 5110642 tmp_cid = MAPCOMBO(bx2,by2);
19231 5110642 tmp_cmb = &combobuf[tmp_cid];
19232
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5110642 times.
✓ Branch 2 taken 5110056 times.
✓ Branch 3 taken 586 times.
10221284 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19233 5110642 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, -1))
19234 {
19235 586 found = tmp_cid;
19236 586 fx = bx2; fy = by2;
19237
2/2
✓ Branch 0 taken 1172 times.
✓ Branch 1 taken 586 times.
1758 for (int32_t i = 0; i <= 1; ++i)
19238 {
19239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if(tmpscr2[i].valid!=0)
19240 {
19241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
1172 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19242 {
19243 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19244 }
19245 else
19246 {
19247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1172 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1172 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[i]))) found = -1;
19248 }
19249 1172 }
19250 1172 }
19251 586 }
19252
19253
2/2
✓ Branch 0 taken 4955847 times.
✓ Branch 1 taken 154795 times.
5110642 if (!get_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY))
19254 {
19255 154795 word c = tmpscr->numFFC();
19256
2/2
✓ Branch 0 taken 154795 times.
✓ Branch 1 taken 823067 times.
977862 for(word i=0; i<c; i++)
19257 {
19258
4/4
✓ Branch 0 taken 815230 times.
✓ Branch 1 taken 7837 times.
✓ Branch 2 taken 710 times.
✓ Branch 3 taken 814520 times.
823067 if (ffcIsAt(i, bx, by) || ffcIsAt(i, bx2, by2))
19259 {
19260 8547 ffcdata& ffc = tmpscr->ffcs[i];
19261 8547 tmp_cmb = &combobuf[ffc.getData()];
19262
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8547 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8547 times.
8547 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19263 8547 || tmp_cmb->triggerbtn) && true) //!TODO: FFC effect flag?
19264 {
19265 foundffc = i;
19266 break;
19267 }
19268 8547 }
19269 823067 }
19270 154795 }
19271
19272
3/4
✓ Branch 0 taken 5109993 times.
✓ Branch 1 taken 649 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5109993 times.
5110642 if(found<0 && foundffc < 0)
19273 {
19274
2/2
✓ Branch 0 taken 5109421 times.
✓ Branch 1 taken 30657098 times.
35766519 for(int32_t i=0; i<6; i++)
19275 {
19276 30657098 tmp_cid = MAPCOMBO2(i,bx,by);
19277 30657098 tmp_cmb = &combobuf[tmp_cid];
19278
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30657098 times.
✓ Branch 2 taken 30656526 times.
✓ Branch 3 taken 572 times.
61314196 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19279 30657098 || tmp_cmb->triggerbtn) && _effectflag(bx,by,1, i))
19280 {
19281 572 found = tmp_cid;
19282 572 found_lyr = i+1;
19283 572 fx = bx; fy = by;
19284
3/4
✓ Branch 0 taken 572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✓ Branch 3 taken 440 times.
572 if (i == 0 && tmpscr2[1].valid!=0)
19285 {
19286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
440 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19287 {
19288
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
440 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19289 440 }
19290 else
19291 {
19292 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1, &(tmpscr2[1]))) found = -1;
19293 }
19294 440 }
19295 572 }
19296 30657098 tmp_cid = MAPCOMBO2(i,bx2,by2);
19297 30657098 tmp_cmb = &combobuf[tmp_cid];
19298
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30657098 times.
✓ Branch 2 taken 30656582 times.
✓ Branch 3 taken 516 times.
61314196 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->triggerflags[0] & combotriggerONLYGENTRIG))
19299 30657098 || tmp_cmb->triggerbtn) && _effectflag(bx2,by2,1, i))
19300 {
19301 516 found = tmp_cid;
19302 516 found_lyr = i+1;
19303 516 fx = bx2; fy = by2;
19304
3/4
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 390 times.
516 if (i == 0 && tmpscr2[1].valid!=0)
19305 {
19306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
19307 {
19308
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
390 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19309 390 }
19310 else
19311 {
19312 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1, &(tmpscr2[1]))) found = -1;
19313 }
19314 390 }
19315 516 }
19316
2/2
✓ Branch 0 taken 30656526 times.
✓ Branch 1 taken 572 times.
30657098 if(found>-1) break;
19317 30656526 }
19318 5109993 }
19319
19320
3/4
✓ Branch 0 taken 5109421 times.
✓ Branch 1 taken 1221 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5109421 times.
5110642 if(found<0&&foundffc<0) return;
19321
1/2
✓ Branch 0 taken 1221 times.
✗ Branch 1 not taken.
1221 newcombo const& cmb = (foundffc<0?combobuf[found]:combobuf[tmpscr->ffcs[foundffc].getData()]);
19322
19323 1221 byte signInput = 0;
19324 1221 bool didsign = false;
19325
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1221 if(cmb.type == cSIGNPOST && !(cmb.triggerflags[0] & combotriggerONLYGENTRIG))
19326 {
19327 switch(dir)
19328 {
19329 case up:
19330 if(cmb.usrflags&cflag10)
19331 goto endsigns;
19332 break;
19333 case down:
19334 if(cmb.usrflags&cflag9)
19335 goto endsigns;
19336 break;
19337 case left:
19338 if(cmb.usrflags&cflag12)
19339 goto endsigns;
19340 break;
19341 case right:
19342 if(cmb.usrflags&cflag11)
19343 goto endsigns;
19344 break;
19345 }
19346 int32_t intbtn = cmb.attribytes[2];
19347
19348 if(intbtn) //
19349 {
19350 signInput = getIntBtnInput(intbtn, true, true, false, false);
19351 if(!signInput)
19352 {
19353 if(cmb.usrflags & cflag13) //display prompt
19354 {
19355 prompt_combo = cmb.attributes[1]/10000;
19356 prompt_cset = cmb.attribytes[4];
19357 prompt_x = cmb.attrishorts[0];
19358 prompt_y = cmb.attrishorts[1];
19359 }
19360 goto endsigns; //Button not pressed
19361 }
19362 }
19363 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
19364
19365 trigger_sign(cmb);
19366 didsign = true;
19367 }
19368 endsigns:
19369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 if(!cmb.triggerbtn) return;
19370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1221 times.
1221 if(on_cooldown(found_lyr, COMBOPOS(fx,fy))) return;
19371
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 253 times.
✓ Branch 2 taken 431 times.
✓ Branch 3 taken 309 times.
✓ Branch 4 taken 228 times.
1221 switch(dir)
19372 {
19373 case down:
19374
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!(cmb.triggerflags[0] & combotriggerBTN_TOP))
19375 return;
19376 253 break;
19377 case up:
19378
1/2
✓ Branch 0 taken 431 times.
✗ Branch 1 not taken.
431 if(!(cmb.triggerflags[0] & combotriggerBTN_BOTTOM))
19379 return;
19380 431 break;
19381 case right:
19382
1/2
✓ Branch 0 taken 309 times.
✗ Branch 1 not taken.
309 if(!(cmb.triggerflags[0] & combotriggerBTN_LEFT))
19383 return;
19384 309 break;
19385 case left:
19386
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 75 times.
228 if(!(cmb.triggerflags[0] & combotriggerBTN_RIGHT))
19387 75 return;
19388 153 break;
19389 }
19390
3/4
✓ Branch 0 taken 1114 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1114 times.
1146 if(getIntBtnInput(cmb.triggerbtn, true, true, false, false) || checkIntBtnVal(cmb.triggerbtn, signInput))
19391 {
19392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if (foundffc >= 0)
19393 do_trigger_combo_ffc(foundffc, didsign ? ctrigIGNORE_SIGN : 0);
19394 else
19395 32 do_trigger_combo(found_lyr, COMBOPOS(fx,fy), didsign ? ctrigIGNORE_SIGN : 0);
19396 32 }
19397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1114 times.
1114 else if(cmb.type == cBUTTONPROMPT)
19398 {
19399 prompt_combo = cmb.attributes[0]/10000;
19400 prompt_cset = cmb.attribytes[0];
19401 prompt_x = cmb.attrishorts[0];
19402 prompt_y = cmb.attrishorts[1];
19403 }
19404
1/2
✓ Branch 0 taken 1114 times.
✗ Branch 1 not taken.
1114 else if(cmb.prompt_cid)
19405 {
19406 1114 prompt_combo = cmb.prompt_cid;
19407 1114 prompt_cset = cmb.prompt_cs;
19408 1114 prompt_x = cmb.prompt_x;
19409 1114 prompt_y = cmb.prompt_y;
19410 1114 }
19411 5152514 }
19412
19413 5145819 void HeroClass::checklocked()
19414 {
19415
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 5132413 times.
5145819 if(toogam) return; //Walk through walls.
19416
19417
2/2
✓ Branch 0 taken 2988074 times.
✓ Branch 1 taken 2144339 times.
5132413 if(!isdungeon()) return;
19418
19419
4/4
✓ Branch 0 taken 2987436 times.
✓ Branch 1 taken 638 times.
✓ Branch 2 taken 6138 times.
✓ Branch 3 taken 2981298 times.
2988074 if( !diagonalMovement && pushing!=8) return;
19420 /*This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
19421 */
19422
4/4
✓ Branch 0 taken 638 times.
✓ Branch 1 taken 6138 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 628 times.
6776 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
19423
19424
19425 6148 bool found = false;
19426
2/2
✓ Branch 0 taken 24592 times.
✓ Branch 1 taken 6148 times.
30740 for ( int32_t q = 0; q < 4; q++ ) {
19427
4/4
✓ Branch 0 taken 24025 times.
✓ Branch 1 taken 567 times.
✓ Branch 2 taken 246 times.
✓ Branch 3 taken 23779 times.
24592 if ( tmpscr->door[q] == dLOCKED || tmpscr->door[q] == dBOSS ) { found = true; }
19428 24592 }
19429
19430
2/2
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 5366 times.
6148 if ( !found ) return;
19431
19432 782 int32_t si = (currmap<<7) + currscr;
19433 782 int32_t di = 0;
19434
19435
19436
19437
2/4
✓ Branch 0 taken 782 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 782 times.
782 if ( diagonalMovement || get_bit(quest_rules, qr_DISABLE_4WAY_GRIDLOCK))
19438 {
19439 //Up door
19440 if ( y <= 32 && x >= 112 && x <= 128 )
19441 {
19442 if (
19443 dir == up || dir == l_up || dir == r_up //|| Up() || ( Up()&&Left()) || ( Up()&&Right())
19444
19445 )
19446 {
19447 di = nextscr(up);
19448 if(tmpscr->door[0]==dLOCKED)
19449 {
19450 if(usekey())
19451 {
19452 putdoor(scrollbuf,0,up,dUNLOCKED);
19453 tmpscr->door[0]=dUNLOCKED;
19454 setmapflag(si, mDOOR_UP);
19455
19456 if(di != 0xFFFF)
19457 setmapflag(di, mDOOR_DOWN);
19458 sfx(WAV_DOOR);
19459 markBmap(-1);
19460 }
19461 else return;
19462 }
19463 else if(tmpscr->door[0]==dBOSS)
19464 {
19465 if(game->lvlitems[dlevel]&liBOSSKEY)
19466 {
19467 putdoor(scrollbuf,0,up,dOPENBOSS);
19468 tmpscr->door[0]=dOPENBOSS;
19469 setmapflag(si, mDOOR_UP);
19470
19471 if(di != 0xFFFF)
19472 setmapflag(di, mDOOR_DOWN);
19473 sfx(WAV_DOOR);
19474 markBmap(-1);
19475 // Run Boss Key Script
19476 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19477 for ( int32_t q = 0; q < MAXITEMS; ++q )
19478 {
19479 if ( itemsbuf[q].family == itype_bosskey )
19480 {
19481 key_item = q; break;
19482 }
19483 }
19484 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19485 {
19486 ri = &(itemScriptData[key_item]);
19487 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19488 ri->Clear();
19489 item_doscript[key_item] = 1;
19490 itemscriptInitialised[key_item] = 0;
19491 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19492 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19493 }
19494 }
19495 else return;
19496
19497 }
19498
19499 }
19500 }
19501 //Down
19502 if ( y >= 128 && x >= 112 && x <= 128 )
19503 {
19504 if ( dir == down || dir == l_down || dir == r_down ) //|| Down() || ( Down()&&Left()) || ( Down()&&Right()))
19505 {
19506 di = nextscr(down);
19507 if(tmpscr->door[1]==dLOCKED)
19508 {
19509 if(usekey())
19510 {
19511 putdoor(scrollbuf,0,down,dUNLOCKED);
19512 tmpscr->door[1]=dUNLOCKED;
19513 setmapflag(si, mDOOR_DOWN);
19514
19515 if(di != 0xFFFF)
19516 setmapflag(di, mDOOR_UP);
19517 sfx(WAV_DOOR);
19518 markBmap(-1);
19519 }
19520 else return;
19521 }
19522 else if(tmpscr->door[1]==dBOSS)
19523 {
19524 if(game->lvlitems[dlevel]&liBOSSKEY)
19525 {
19526 putdoor(scrollbuf,0,down,dOPENBOSS);
19527 tmpscr->door[1]=dOPENBOSS;
19528 setmapflag(si, mDOOR_DOWN);
19529
19530 if(di != 0xFFFF)
19531 setmapflag(di, mDOOR_UP);
19532 sfx(WAV_DOOR);
19533 markBmap(-1);
19534 // Run Boss Key Script
19535 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19536 for ( int32_t q = 0; q < MAXITEMS; ++q )
19537 {
19538 if ( itemsbuf[q].family == itype_bosskey )
19539 {
19540 key_item = q; break;
19541 }
19542 }
19543 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19544 {
19545 ri = &(itemScriptData[key_item]);
19546 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19547 ri->Clear();
19548 item_doscript[key_item] = 1;
19549 itemscriptInitialised[key_item] = 0;
19550 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19551 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19552 }
19553 }
19554 else return;
19555 }
19556 }
19557 }
19558 //left
19559 if ( y > 72 && y < 88 && x <= 32 )
19560 {
19561 if ( dir == left || dir == l_up || dir == l_down )//|| Left() || ( Up()&&Left()) || ( Down()&&Left() ) )
19562 {
19563 di = nextscr(left);
19564 if(tmpscr->door[2]==dLOCKED)
19565 {
19566 if(usekey())
19567 {
19568 putdoor(scrollbuf,0,left,dUNLOCKED);
19569 tmpscr->door[2]=dUNLOCKED;
19570 setmapflag(si, mDOOR_LEFT);
19571
19572 if(di != 0xFFFF)
19573 setmapflag(di, mDOOR_RIGHT);
19574 sfx(WAV_DOOR);
19575 markBmap(-1);
19576 }
19577 else return;
19578 }
19579 else if(tmpscr->door[2]==dBOSS)
19580 {
19581 if(game->lvlitems[dlevel]&liBOSSKEY)
19582 {
19583 putdoor(scrollbuf,0,left,dOPENBOSS);
19584 tmpscr->door[2]=dOPENBOSS;
19585 setmapflag(si, mDOOR_LEFT);
19586
19587 if(di != 0xFFFF)
19588 setmapflag(di, mDOOR_RIGHT);
19589 sfx(WAV_DOOR);
19590 markBmap(-1);
19591 // Run Boss Key Script
19592 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19593 for ( int32_t q = 0; q < MAXITEMS; ++q )
19594 {
19595 if ( itemsbuf[q].family == itype_bosskey )
19596 {
19597 key_item = q; break;
19598 }
19599 }
19600 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19601 {
19602 ri = &(itemScriptData[key_item]);
19603 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19604 ri->Clear();
19605 item_doscript[key_item] = 1;
19606 itemscriptInitialised[key_item] = 0;
19607 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19608 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19609 }
19610 }
19611 else return;
19612 }
19613 }
19614 }
19615
19616
19617 //right
19618 if ( ( y > 72 && y < 88 ) && x >= 208 )
19619 //!( (y<=72||y>=88) && x<206 ) )
19620 //y<=72||y>=88):y!=80) || x<208)
19621 {
19622 if ( dir == right || dir == r_up || dir == r_down ) //|| Right() || ( Down()&&Right() ) || ( Up()&&Right()))
19623 {
19624 di = nextscr(right);
19625 if(tmpscr->door[right]==dLOCKED)
19626 {
19627 if(usekey())
19628 {
19629 putdoor(scrollbuf,0,right,dUNLOCKED);
19630 tmpscr->door[3]=dUNLOCKED;
19631 setmapflag(si, mDOOR_RIGHT);
19632
19633 if(di != 0xFFFF)
19634 setmapflag(di, mDOOR_LEFT);
19635 sfx(WAV_DOOR);
19636 markBmap(-1);
19637 }
19638 else return;
19639 }
19640 else if(tmpscr->door[right]==dBOSS)
19641 {
19642 if(game->lvlitems[dlevel]&liBOSSKEY)
19643 {
19644 putdoor(scrollbuf,0,right,dOPENBOSS);
19645 tmpscr->door[3]=dOPENBOSS;
19646 setmapflag(si, mDOOR_RIGHT);
19647
19648 if(di != 0xFFFF)
19649 setmapflag(di, mDOOR_LEFT);
19650 sfx(WAV_DOOR);
19651 markBmap(-1);
19652 // Run Boss Key Script
19653 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19654 for ( int32_t q = 0; q < MAXITEMS; ++q )
19655 {
19656 if ( itemsbuf[q].family == itype_bosskey )
19657 {
19658 key_item = q; break;
19659 }
19660 }
19661 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19662 {
19663 ri = &(itemScriptData[key_item]);
19664 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19665 ri->Clear();
19666 item_doscript[key_item] = 1;
19667 itemscriptInitialised[key_item] = 0;
19668 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19669 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19670 }
19671 }
19672 else return;
19673 }
19674
19675 }
19676 }
19677 }
19678 else
19679 {
19680 //orthogonal movement
19681 //Up door
19682
4/4
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 630 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 89 times.
782 if ( y<=32 && x == 120 )
19683 //!( y>32 && (x!=120) ))
19684 {
19685
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 1 times.
89 switch ( dir )
19686 {
19687 case up:
19688 case r_up:
19689 case l_up:
19690 {
19691 88 di = nextscr(up);
19692
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 25 times.
88 if(tmpscr->door[0]==dLOCKED)
19693 {
19694
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 3 times.
63 if(usekey())
19695 {
19696 60 putdoor(scrollbuf,0,up,dUNLOCKED);
19697 60 tmpscr->door[0]=dUNLOCKED;
19698 60 setmapflag(si, mDOOR_UP);
19699
19700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(di != 0xFFFF)
19701 60 setmapflag(di, mDOOR_DOWN);
19702 60 sfx(WAV_DOOR);
19703 60 markBmap(-1);
19704 60 }
19705 3 else return;
19706 60 }
19707
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 15 times.
25 else if(tmpscr->door[0]==dBOSS)
19708 {
19709
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if(game->lvlitems[dlevel]&liBOSSKEY)
19710 {
19711 14 putdoor(scrollbuf,0,up,dOPENBOSS);
19712 14 tmpscr->door[0]=dOPENBOSS;
19713 14 setmapflag(si, mDOOR_UP);
19714
19715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(di != 0xFFFF)
19716 14 setmapflag(di, mDOOR_DOWN);
19717 14 sfx(WAV_DOOR);
19718 14 markBmap(-1);
19719 // Run Boss Key Script
19720 14 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 for ( int32_t q = 0; q < MAXITEMS; ++q )
19722 {
19723
2/2
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
952 if ( itemsbuf[q].family == itype_bosskey )
19724 {
19725 14 key_item = q; break;
19726 }
19727 938 }
19728
2/8
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19729 {
19730 ri = &(itemScriptData[key_item]);
19731 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19732 ri->Clear();
19733 item_doscript[key_item] = 1;
19734 itemscriptInitialised[key_item] = 0;
19735 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19736 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19737 }
19738 14 }
19739 1 else return;
19740 14 }
19741 84 break;
19742 }
19743 1 default: break;
19744
19745 }
19746 85 }
19747 //Down
19748
4/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 26 times.
778 if ( y >= 128 && x == 120 )
19749 //!(y<128 && (x!=120) ) )
19750 {
19751
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 3 times.
26 switch(dir)
19752 {
19753 case down:
19754 case l_down:
19755 case r_down:
19756 {
19757 23 di = nextscr(down);
19758
19759
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 10 times.
23 if(tmpscr->door[1]==dLOCKED)
19760 {
19761
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
13 if(usekey())
19762 {
19763 12 putdoor(scrollbuf,0,down,dUNLOCKED);
19764 12 tmpscr->door[1]=dUNLOCKED;
19765 12 setmapflag(si, mDOOR_DOWN);
19766
19767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(di != 0xFFFF)
19768 12 setmapflag(di, mDOOR_UP);
19769 12 sfx(WAV_DOOR);
19770 12 markBmap(-1);
19771 12 }
19772 1 else return;
19773 12 }
19774
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
10 else if(tmpscr->door[1]==dBOSS)
19775 {
19776
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
19777 {
19778 4 putdoor(scrollbuf,0,down,dOPENBOSS);
19779 4 tmpscr->door[1]=dOPENBOSS;
19780 4 setmapflag(si, mDOOR_DOWN);
19781
19782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
19783 4 setmapflag(di, mDOOR_UP);
19784 4 sfx(WAV_DOOR);
19785 4 markBmap(-1);
19786 // Run Boss Key Script
19787 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
19789 {
19790
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
19791 {
19792 4 key_item = q; break;
19793 }
19794 268 }
19795
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19796 {
19797 ri = &(itemScriptData[key_item]);
19798 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19799 ri->Clear();
19800 item_doscript[key_item] = 1;
19801 itemscriptInitialised[key_item] = 0;
19802 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19803 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19804 }
19805 4 }
19806 1 else return;
19807 4 }
19808 21 break;
19809 }
19810 3 default: break;
19811 }
19812 24 }
19813 //left
19814
4/4
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 49 times.
776 if ( y == 80 && x <= 32 )
19815 //!( (y!=80) && x>32 ) )
19816 {
19817
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 8 times.
49 switch(dir)
19818 {
19819 case left:
19820 case l_up:
19821 case l_down:
19822 {
19823 41 di = nextscr(left);
19824
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 12 times.
41 if(tmpscr->door[2]==dLOCKED)
19825 {
19826
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(usekey())
19827 {
19828 27 putdoor(scrollbuf,0,left,dUNLOCKED);
19829 27 tmpscr->door[2]=dUNLOCKED;
19830 27 setmapflag(si, mDOOR_LEFT);
19831
19832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(di != 0xFFFF)
19833 27 setmapflag(di, mDOOR_RIGHT);
19834 27 sfx(WAV_DOOR);
19835 27 markBmap(-1);
19836 27 }
19837 2 else return;
19838 27 }
19839
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 5 times.
12 else if(tmpscr->door[2]==dBOSS)
19840 {
19841
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 if(game->lvlitems[dlevel]&liBOSSKEY)
19842 {
19843 4 putdoor(scrollbuf,0,left,dOPENBOSS);
19844 4 tmpscr->door[2]=dOPENBOSS;
19845 4 setmapflag(si, mDOOR_LEFT);
19846
19847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(di != 0xFFFF)
19848 4 setmapflag(di, mDOOR_RIGHT);
19849 4 sfx(WAV_DOOR);
19850 4 markBmap(-1);
19851 // Run Boss Key Script
19852 4 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272 times.
272 for ( int32_t q = 0; q < MAXITEMS; ++q )
19854 {
19855
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 4 times.
272 if ( itemsbuf[q].family == itype_bosskey )
19856 {
19857 4 key_item = q; break;
19858 }
19859 268 }
19860
2/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) )
19861 {
19862 ri = &(itemScriptData[key_item]);
19863 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19864 ri->Clear();
19865 item_doscript[key_item] = 1;
19866 itemscriptInitialised[key_item] = 0;
19867 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19868 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19869 }
19870 4 }
19871 1 else return;
19872 4 }
19873
19874 38 break;
19875
19876 }
19877 8 default: break;
19878 }
19879 46 }
19880 //right
19881
4/4
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 618 times.
✓ Branch 2 taken 95 times.
✓ Branch 3 taken 60 times.
773 if ( y == 80 && x >= 208 )
19882 //!((y!=80) && x<208 ) )
19883 {
19884
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 3 times.
60 switch(dir)
19885 {
19886 case right:
19887 case r_down:
19888 case r_up:
19889 {
19890 57 di = nextscr(right);
19891
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 18 times.
57 if(tmpscr->door[3]==dLOCKED)
19892 {
19893
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 3 times.
39 if(usekey())
19894 {
19895 36 putdoor(scrollbuf,0,right,dUNLOCKED);
19896 36 tmpscr->door[3]=dUNLOCKED;
19897 36 setmapflag(si, mDOOR_RIGHT);
19898
19899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(di != 0xFFFF)
19900 36 setmapflag(di, mDOOR_LEFT);
19901 36 sfx(WAV_DOOR);
19902 36 markBmap(-1);
19903 36 }
19904 3 else return;
19905 36 }
19906
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 8 times.
18 else if(tmpscr->door[3]==dBOSS)
19907 {
19908
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1 times.
8 if(game->lvlitems[dlevel]&liBOSSKEY)
19909 {
19910 7 putdoor(scrollbuf,0,right,dOPENBOSS);
19911 7 tmpscr->door[3]=dOPENBOSS;
19912 7 setmapflag(si, mDOOR_RIGHT);
19913
19914
19915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(di != 0xFFFF)
19916 7 setmapflag(di, mDOOR_LEFT);
19917 7 sfx(WAV_DOOR);
19918 7 markBmap(-1);
19919 // Run Boss Key Script
19920 7 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
19921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 476 times.
476 for ( int32_t q = 0; q < MAXITEMS; ++q )
19922 {
19923
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 7 times.
476 if ( itemsbuf[q].family == itype_bosskey )
19924 {
19925 7 key_item = q; break;
19926 }
19927 469 }
19928
2/8
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7 if ( key_item > 0 && itemsbuf[key_item].script && !(item_doscript[key_item] && get_bit(quest_rules,qr_ITEMSCRIPTSKEEPRUNNING)) ) //
19929 {
19930 ri = &(itemScriptData[key_item]);
19931 for ( int32_t q = 0; q < 1024; q++ ) item_stack[key_item][q] = 0xFFFF;
19932 ri->Clear();
19933 item_doscript[key_item] = 1;
19934 itemscriptInitialised[key_item] = 0;
19935 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[key_item].script, key_item);
19936 FFCore.deallocateAllArrays(SCRIPT_ITEM,(key_item));
19937 }
19938
19939 7 }
19940 1 else return;
19941 7 }
19942
19943
19944 53 break;
19945 }
19946 3 default: break;
19947
19948 }
19949 56 }
19950 }
19951 5145819 }
19952
19953 5145819 void HeroClass::checkswordtap()
19954 {
19955
6/6
✓ Branch 0 taken 2527348 times.
✓ Branch 1 taken 2618471 times.
✓ Branch 2 taken 1913 times.
✓ Branch 3 taken 2525435 times.
✓ Branch 4 taken 1902 times.
✓ Branch 5 taken 11 times.
5145819 if(attack!=wSword || charging<=0 || pushing<8) return;
19956
19957 11 int32_t bx=x;
19958 11 int32_t by=y+8;
19959
19960
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
11 switch(dir)
19961 {
19962 case up:
19963
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!Up()) return;
19964
19965 11 by-=16;
19966 11 break;
19967
19968 case down:
19969 if(!Down()) return;
19970
19971 by+=16;
19972 bx+=8;
19973 break;
19974
19975 case left:
19976 if(!Left()) return;
19977
19978 bx-=16;
19979 by+=8;
19980 break;
19981
19982 case right:
19983 if(!Right()) return;
19984
19985 bx+=16;
19986 by+=8;
19987 break;
19988 }
19989
19990
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
11 if(!_walkflag(bx,by,0,SWITCHBLOCK_STATE)) return;
19991
19992 11 attackclk=SWORDTAPFRAME;
19993 11 pushing=-8; //16 frames between taps
19994 11 tapping=true;
19995
19996 11 int32_t type = COMBOTYPE(bx,by);
19997
19998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(!isCuttableType(type))
19999 {
20000
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
22 bool hollow = (MAPFLAG(bx,by) == mfBOMB || MAPCOMBOFLAG(bx,by) == mfBOMB ||
20001
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 MAPFLAG(bx,by) == mfSBOMB || MAPCOMBOFLAG(bx,by) == mfSBOMB);
20002
20003 // Layers
20004
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 11 times.
77 for(int32_t i=0; i < 6; i++)
20005
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
132 hollow = (hollow || MAPFLAG2(i,bx,by) == mfBOMB || MAPCOMBOFLAG2(i,bx,by) == mfBOMB ||
20006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 MAPFLAG2(i,bx,by) == mfSBOMB || MAPCOMBOFLAG2(i,bx,by) == mfSBOMB);
20007
20008
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11 times.
55 for(int32_t i=0; i<4; i++)
20009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if(tmpscr->door[i]==dBOMB && i==dir)
20010 switch(i)
20011 {
20012 case up:
20013 case down:
20014 if(bx>=112 && bx<144 && (by>=144 || by<=32)) hollow=true;
20015
20016 break;
20017
20018 case left:
20019 case right:
20020 if(by>=72 && by<104 && (bx>=224 || bx<=32)) hollow=true;
20021
20022 break;
20023 }
20024
20025 11 sfx(hollow ? WAV_ZN1TAP2 : WAV_ZN1TAP,pan(x.getInt()));
20026 11 }
20027
20028 5145819 }
20029
20030 17891 void HeroClass::fairycircle(int32_t type)
20031 {
20032
2/2
✓ Branch 0 taken 14944 times.
✓ Branch 1 taken 2947 times.
17891 if(fairyclk==0)
20033 {
20034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2947 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2947 switch(type)
20035 {
20036 case REFILL_LIFE:
20037
2/2
✓ Branch 0 taken 2855 times.
✓ Branch 1 taken 92 times.
2947 if(didstuff&did_fairy) return;
20038
20039 92 didstuff|=did_fairy;
20040 92 break;
20041
20042 case REFILL_MAGIC:
20043 if(didstuff&did_magic) return;
20044
20045 didstuff|=did_magic;
20046 break;
20047
20048 case REFILL_ALL:
20049 if(didstuff&did_all) return;
20050
20051 didstuff|=did_all;
20052 }
20053
20054 92 refill_what=type;
20055 92 refill_why=REFILL_FAIRY;
20056 92 StartRefill(type);
20057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
20058 92 else {action=freeze; FFCore.setHeroAction(freeze);}
20059 92 holdclk=0;
20060 92 hopclk=0;
20061 92 }
20062
20063 15036 ++fairyclk;
20064
20065
2/2
✓ Branch 0 taken 7584 times.
✓ Branch 1 taken 7452 times.
15036 if(refilling!=REFILL_FAIRYDONE)
20066 {
20067
2/2
✓ Branch 0 taken 7492 times.
✓ Branch 1 taken 92 times.
7584 if(!refill())
20068 92 refilling=REFILL_FAIRYDONE;
20069 7584 }
20070
20071
2/2
✓ Branch 0 taken 7360 times.
✓ Branch 1 taken 92 times.
7452 else if(++holdclk>80)
20072 {
20073 92 reset_swordcharge();
20074 92 attackclk=0;
20075 92 action=none; FFCore.setHeroAction(none);
20076 92 fairyclk=0;
20077 92 holdclk=0;
20078 92 refill_why = 0;
20079 92 refilling=REFILL_NONE;
20080 92 map_bkgsfx(true);
20081 92 }
20082 17891 }
20083
20084 500333 int32_t touchcombo(int32_t x,int32_t y)
20085 {
20086
2/2
✓ Branch 0 taken 1000666 times.
✓ Branch 1 taken 500333 times.
1500999 for (int32_t i = 0; i <= 1; ++i)
20087 {
20088
2/2
✓ Branch 0 taken 810445 times.
✓ Branch 1 taken 190221 times.
1000666 if(tmpscr2[i].valid!=0)
20089 {
20090
2/2
✓ Branch 0 taken 182384 times.
✓ Branch 1 taken 7837 times.
190221 if (get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
20091 {
20092
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 182384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
182384 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
20093 182384 }
20094 else
20095 {
20096
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7837 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7837 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,1, &(tmpscr2[i]))) return 0;
20097 }
20098 190221 }
20099 1000666 }
20100
2/2
✓ Branch 0 taken 499685 times.
✓ Branch 1 taken 648 times.
500333 if (!_effectflag(x,y,1, -1)) return 0;
20101 499685 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
20102
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 499637 times.
499685 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
20103 48 return 0;
20104
3/3
✓ Branch 0 taken 2743 times.
✓ Branch 1 taken 495480 times.
✓ Branch 2 taken 1414 times.
499637 switch(cmb.type)
20105 {
20106 case cBSGRAVE:
20107 case cGRAVE:
20108
3/4
✓ Branch 0 taken 1814 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 1814 times.
✗ Branch 3 not taken.
2743 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
20109 {
20110 929 break;
20111 }
20112
20113 [[fallthrough]];
20114 case cARMOS:
20115 {
20116 3228 return cmb.type;
20117 }
20118 }
20119
20120 496409 return 0;
20121 500333 }
20122
20123 //static int32_t COMBOX(int32_t pos) { return ((pos)%16*16); }
20124 //static int32_t COMBOY(int32_t pos) { return ((pos)&0xF0); }
20125
20126 static int32_t GridX(int32_t x)
20127 {
20128 return (x >> 4) << 4;
20129 }
20130
20131 //Snaps 'y' to the combo grid
20132 //Equivalent to calling ComboY(ComboAt(foo,y));
20133 static int32_t GridY(int32_t y)
20134 {
20135 return (y >> 4) << 4;
20136 }
20137
20138 30 int32_t grabComboFromPos(int32_t pos, int32_t type)
20139 {
20140
1/2
✓ Branch 0 taken 210 times.
✗ Branch 1 not taken.
210 for(int32_t lyr = 6; lyr > -1; --lyr)
20141 {
20142 210 int32_t id = FFCore.tempScreens[lyr]->data[pos];
20143
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 180 times.
210 if(combobuf[id].type == type)
20144 30 return id;
20145 180 }
20146 return -1;
20147 30 }
20148
20149 static int32_t typeMap[176];
20150 static int32_t istrig[176];
20151 static const int32_t SPTYPE_SOLID = -1;
20152 #define SP_VISITED 0x1
20153 #define SPFLAG(dir) (0x2<<dir)
20154 #define BEAM_AGE_LIMIT 32
20155 1234 void HeroClass::handleBeam(byte* grid, size_t age, byte spotdir, int32_t curpos, byte set, bool block, bool refl)
20156 {
20157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = set ? (1 << (set-1)) : ~0;
20158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(spotdir > 3) return; //invalid dir
20159 1234 bool doAge = true;
20160 1234 byte f = 0;
20161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13668 times.
13668 while(unsigned(curpos) < 176)
20162 {
20163 13668 bool block_light = false;
20164 13668 f = SPFLAG(spotdir);
20165
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 13341 times.
13668 if((grid[curpos] & f) != f)
20166 {
20167 13341 grid[curpos] |= f;
20168 13341 istrig[curpos] |= trigflag;
20169 13341 doAge = false;
20170 13341 age = 0;
20171 13341 }
20172
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 652 times.
✓ Branch 3 taken 12657 times.
✓ Branch 4 taken 183 times.
13668 switch(spotdir)
20173 {
20174 case up:
20175 176 curpos -= 0x10;
20176 176 break;
20177 case down:
20178 652 curpos += 0x10;
20179 652 break;
20180 case left:
20181
1/2
✓ Branch 0 taken 12657 times.
✗ Branch 1 not taken.
12657 if(!(curpos%0x10))
20182 curpos = -1;
20183 12657 else --curpos;
20184 12657 break;
20185 case right:
20186 183 ++curpos;
20187
1/2
✓ Branch 0 taken 183 times.
✗ Branch 1 not taken.
183 if(!(curpos%0x10))
20188 curpos = -1;
20189 183 break;
20190 }
20191
1/2
✓ Branch 0 taken 13668 times.
✗ Branch 1 not taken.
13668 if(unsigned(curpos) >= 176) break;
20192
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 12440 times.
13668 switch(typeMap[curpos])
20193 {
20194 case SPTYPE_SOLID: case cBLOCKALL:
20195 1228 curpos = -1;
20196 1228 break;
20197 }
20198
3/6
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 13371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13668 if((curpos==COMBOPOS(x.getInt()+8,y.getInt()+8)) && block && (spotdir == oppositeDir[dir]))
20199 curpos = -1;
20200
2/2
✓ Branch 0 taken 12440 times.
✓ Branch 1 taken 1228 times.
13668 if(unsigned(curpos) >= 176) break;
20201
20202 12440 f = SPFLAG(oppositeDir[spotdir]);
20203
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if((grid[curpos] & f) != f)
20204 {
20205 12113 grid[curpos] |= f;
20206 12113 istrig[curpos] |= trigflag;
20207 12113 doAge = false;
20208 12113 age = 0;
20209 12113 }
20210
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 12113 times.
12440 if(doAge)
20211 {
20212
2/2
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 6 times.
327 if(++age > BEAM_AGE_LIMIT)
20213 6 break;
20214 321 }
20215 12113 else doAge = true;
20216
20217
3/4
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 12137 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 297 times.
12434 if(curpos==COMBOPOS(x.getInt()+8,y.getInt() +8) && refl)
20218 297 spotdir = dir;
20219
2/7
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 12107 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
12137 else switch(typeMap[curpos])
20220 {
20221 case cLIGHTTARGET:
20222
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(combobuf[grabComboFromPos(curpos, cLIGHTTARGET)].usrflags&cflag3) //Blocks light
20223 return;
20224 case cMIRROR:
20225 30 spotdir = oppositeDir[spotdir];
20226 30 break;
20227 case cMIRRORSLASH:
20228 switch(spotdir)
20229 {
20230 case up:
20231 spotdir = right; break;
20232 case right:
20233 spotdir = up; break;
20234 case down:
20235 spotdir = left; break;
20236 case left:
20237 spotdir = down; break;
20238 }
20239 break;
20240 case cMIRRORBACKSLASH:
20241 switch(spotdir)
20242 {
20243 case up:
20244 spotdir = left; break;
20245 case left:
20246 spotdir = up; break;
20247 case down:
20248 spotdir = right; break;
20249 case right:
20250 spotdir = down; break;
20251 }
20252 break;
20253 case cMAGICPRISM:
20254 for(byte d = 0; d < 4; ++d)
20255 {
20256 if(d == oppositeDir[spotdir]) continue;
20257 handleBeam(grid, age, d, curpos, set, block, refl);
20258 }
20259 return;
20260 case cMAGICPRISM4:
20261 for(byte d = 0; d < 4; ++d)
20262 {
20263 handleBeam(grid, age, d, curpos, set, block, refl);
20264 }
20265 return;
20266 }
20267 }
20268 1234 }
20269
20270 5152186 void HeroClass::handleSpotlights()
20271 {
20272 typedef byte spot_t;
20273 //Store each different tile/color as grids
20274 5152186 std::map<int32_t, spot_t*> maps;
20275
1/2
✓ Branch 0 taken 5152186 times.
✗ Branch 1 not taken.
5152186 int32_t shieldid = getCurrentShield(false);
20276
2/2
✓ Branch 0 taken 4661438 times.
✓ Branch 1 taken 490748 times.
5152186 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & shLIGHTBEAM);
20277
4/4
✓ Branch 0 taken 5141868 times.
✓ Branch 1 taken 10318 times.
✓ Branch 2 taken 490748 times.
✓ Branch 3 taken 4651120 times.
5152186 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & shLIGHTBEAM);
20278
3/6
✓ Branch 0 taken 5152186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5152186 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5152186 times.
✗ Branch 5 not taken.
5152186 int32_t heropos = COMBOPOS(x.getInt()+8,y.getInt()+8);
20279 5152186 memset(istrig, 0, sizeof(istrig));
20280
1/2
✓ Branch 0 taken 5152186 times.
✗ Branch 1 not taken.
5152186 clear_bitmap(lightbeam_bmp);
20281
20282
2/2
✓ Branch 0 taken 906784736 times.
✓ Branch 1 taken 5152186 times.
911936922 for(size_t pos = 0; pos < 176; ++pos)
20283 {
20284 906784736 typeMap[pos] = 0;
20285
2/2
✓ Branch 0 taken 906571260 times.
✓ Branch 1 taken 6347452544 times.
7254023804 for(int32_t lyr = 6; lyr > -1; --lyr)
20286 {
20287 6347452544 newcombo const* cmb = &combobuf[FFCore.tempScreens[lyr]->data[pos]];
20288
3/3
✓ Branch 0 taken 209774 times.
✓ Branch 1 taken 6347239068 times.
✓ Branch 2 taken 3702 times.
6347452544 switch(cmb->type)
20289 {
20290 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
20291 case cMAGICPRISM: case cMAGICPRISM4:
20292 case cBLOCKALL: case cLIGHTTARGET:
20293 209774 typeMap[pos] = cmb->type;
20294 209774 break;
20295 case cGLASS:
20296 3702 typeMap[pos] = 0;
20297 3702 break;
20298 default:
20299 {
20300
4/4
✓ Branch 0 taken 2720100124 times.
✓ Branch 1 taken 3627138944 times.
✓ Branch 2 taken 2169932926 times.
✓ Branch 3 taken 550167198 times.
6347239068 if(lyr < 3 && (cmb->walk & 0xF))
20301 {
20302 550167198 typeMap[pos] = SPTYPE_SOLID;
20303 550167198 }
20304 6347239068 continue; //next layer
20305 }
20306 }
20307 213476 break; //hit a combo type
20308 }
20309 906784736 }
20310
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 5151997 times.
5152186 if(unsigned(heropos) < 176)
20311 {
20312
2/2
✓ Branch 0 taken 507305 times.
✓ Branch 1 taken 4644692 times.
5151997 switch(typeMap[heropos])
20313 {
20314 case SPTYPE_SOLID: case cBLOCKALL:
20315 507305 heropos = -1; //Blocked from hitting player
20316 507305 }
20317 5151997 }
20318
20319
2/2
✓ Branch 0 taken 36065302 times.
✓ Branch 1 taken 5152186 times.
41217488 for(size_t layer = 0; layer < 7; ++layer)
20320 {
20321 36065302 mapscr* curlayer = FFCore.tempScreens[layer];
20322
2/2
✓ Branch 0 taken 6347493152 times.
✓ Branch 1 taken 36065302 times.
6383558454 for(size_t pos = 0; pos < 176; ++pos)
20323 {
20324 //For each spotlight combo on each layer...
20325 6347493152 newcombo const& cmb = combobuf[curlayer->data[pos]];
20326
2/2
✓ Branch 0 taken 6347491918 times.
✓ Branch 1 taken 1234 times.
6347493152 if(cmb.type == cSPOTLIGHT)
20327 {
20328 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
20329
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
2468 int32_t id = (cmb.usrflags&cflag1)
20330
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 ? std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24
20331 : -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
20332
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(!id) continue;
20333 // zprint2("ID = %ld\n", id);
20334 //Get the grid array for this tile/color
20335 spot_t* grid;
20336
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
1234 if(maps[id])
20337 grid = maps[id];
20338 else
20339 {
20340
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 grid = new spot_t[176];
20341 1234 memset(grid, 0, sizeof(spot_t)*176);
20342
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 maps[id] = grid;
20343 }
20344 1234 byte spotdir = cmb.attribytes[0];
20345 1234 int32_t curpos = pos;
20346
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(spotdir > 3)
20347 {
20348 grid[curpos] |= SP_VISITED;
20349 istrig[curpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
20350 }
20351
2/4
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1234 times.
✗ Branch 3 not taken.
1234 if(refl && curpos == heropos)
20352 {
20353 spotdir = dir;
20354 }
20355
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 handleBeam(grid, 0, spotdir, curpos, cmb.attribytes[4], block, refl);
20356 1234 }
20357 6347493152 }
20358 36065302 }
20359
20360 //Draw visuals
20361
2/2
✓ Branch 0 taken 5152186 times.
✓ Branch 1 taken 1234 times.
5153420 for(auto it = maps.begin(); it != maps.end();)
20362 {
20363 1234 int32_t id = it->first;
20364 1234 spot_t* grid = it->second;
20365 //
20366 enum {t_gr, t_up, t_down, t_left, t_right, t_uleft, t_uright, t_dleft, t_dright, t_vert, t_horz, t_notup, t_notdown, t_notleft, t_notright, t_all, t_max };
20367 1234 int32_t tile = (id&0xFFFFFF);
20368 1234 int32_t cs = (id>>24);
20369 1234 byte c_inner = ((-id)&0x0000FF);
20370 1234 byte c_middle = ((-id)&0x00FF00)>>8;
20371 1234 byte c_outter = ((-id)&0xFF0000)>>16;
20372 //{ Setup color bitmap
20373 1234 BITMAP* cbmp = NULL;
20374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 if(id < 0)
20375 {
20376 //zprint2("Creating with colors: %02X,%02X,%02X\n", c_inner, c_middle, c_outter);
20377 cbmp = create_bitmap_ex(8, 16*t_max, 16);
20378 clear_bitmap(cbmp);
20379 for(size_t q = 1; q < t_max; ++q)
20380 {
20381 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
20382 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
20383 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
20384 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
20385 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
20386 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
20387 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
20388 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
20389 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
20390 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
20391 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
20392 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
20393 }
20394 //t_gr
20395 circlefill(cbmp, 16*t_gr+8, 8, 7, c_outter);
20396 circlefill(cbmp, 16*t_gr+7, 8, 7, c_outter);
20397 circlefill(cbmp, 16*t_gr+8, 7, 7, c_outter);
20398 circlefill(cbmp, 16*t_gr+7, 7, 7, c_outter);
20399 circlefill(cbmp, 16*t_gr+8, 8, 5, c_middle);
20400 circlefill(cbmp, 16*t_gr+7, 8, 5, c_middle);
20401 circlefill(cbmp, 16*t_gr+8, 7, 5, c_middle);
20402 circlefill(cbmp, 16*t_gr+7, 7, 5, c_middle);
20403 circlefill(cbmp, 16*t_gr+8, 8, 3, c_inner);
20404 circlefill(cbmp, 16*t_gr+7, 8, 3, c_inner);
20405 circlefill(cbmp, 16*t_gr+8, 7, 3, c_inner);
20406 circlefill(cbmp, 16*t_gr+7, 7, 3, c_inner);
20407 //t_up
20408 rectfill(cbmp, 16*t_up+4, 0, 16*t_up+11, 7, c_outter);
20409 rectfill(cbmp, 16*t_up+6, 0, 16*t_up+9, 7, c_middle);
20410 rectfill(cbmp, 16*t_up+7, 0, 16*t_up+8, 7, c_inner);
20411 //t_down
20412 rectfill(cbmp, 16*t_down+4, 8, 16*t_down+11, 15, c_outter);
20413 rectfill(cbmp, 16*t_down+6, 8, 16*t_down+9, 15, c_middle);
20414 rectfill(cbmp, 16*t_down+7, 8, 16*t_down+8, 15, c_inner);
20415 //t_left
20416 rectfill(cbmp, 16*t_left, 4, 16*t_left+7, 11, c_outter);
20417 rectfill(cbmp, 16*t_left, 6, 16*t_left+7, 9, c_middle);
20418 rectfill(cbmp, 16*t_left, 7, 16*t_left+7, 8, c_inner);
20419 //t_right
20420 rectfill(cbmp, 16*t_right+8, 4, 16*t_right+15, 11, c_outter);
20421 rectfill(cbmp, 16*t_right+8, 6, 16*t_right+15, 9, c_middle);
20422 rectfill(cbmp, 16*t_right+8, 7, 16*t_right+15, 8, c_inner);
20423 //t_uleft
20424 rectfill(cbmp, 16*t_uleft+4, 0, 16*t_uleft+11, 7, c_outter);
20425 rectfill(cbmp, 16*t_uleft, 4, 16*t_uleft+7, 11, c_outter);
20426 rectfill(cbmp, 16*t_uleft, 6, 16*t_uleft+7, 9, c_middle);
20427 rectfill(cbmp, 16*t_uleft+6, 0, 16*t_uleft+9, 7, c_middle);
20428 rectfill(cbmp, 16*t_uleft+7, 0, 16*t_uleft+8, 7, c_inner);
20429 rectfill(cbmp, 16*t_uleft, 7, 16*t_uleft+7, 8, c_inner);
20430 //t_uright
20431 rectfill(cbmp, 16*t_uright+4, 0, 16*t_uright+11, 7, c_outter);
20432 rectfill(cbmp, 16*t_uright+8, 4, 16*t_uright+15, 11, c_outter);
20433 rectfill(cbmp, 16*t_uright+8, 6, 16*t_uright+15, 9, c_middle);
20434 rectfill(cbmp, 16*t_uright+6, 0, 16*t_uright+9, 7, c_middle);
20435 rectfill(cbmp, 16*t_uright+7, 0, 16*t_uright+8, 7, c_inner);
20436 rectfill(cbmp, 16*t_uright+8, 7, 16*t_uright+15, 8, c_inner);
20437 //t_dleft
20438 rectfill(cbmp, 16*t_dleft+4, 8, 16*t_dleft+11, 15, c_outter);
20439 rectfill(cbmp, 16*t_dleft, 4, 16*t_dleft+7, 11, c_outter);
20440 rectfill(cbmp, 16*t_dleft, 6, 16*t_dleft+7, 9, c_middle);
20441 rectfill(cbmp, 16*t_dleft+6, 8, 16*t_dleft+9, 15, c_middle);
20442 rectfill(cbmp, 16*t_dleft+7, 8, 16*t_dleft+8, 15, c_inner);
20443 rectfill(cbmp, 16*t_dleft, 7, 16*t_dleft+7, 8, c_inner);
20444 //t_dright
20445 rectfill(cbmp, 16*t_dright+4, 8, 16*t_dright+11, 15, c_outter);
20446 rectfill(cbmp, 16*t_dright+8, 4, 16*t_dright+15, 11, c_outter);
20447 rectfill(cbmp, 16*t_dright+8, 6, 16*t_dright+15, 9, c_middle);
20448 rectfill(cbmp, 16*t_dright+6, 8, 16*t_dright+9, 15, c_middle);
20449 rectfill(cbmp, 16*t_dright+7, 8, 16*t_dright+8, 15, c_inner);
20450 rectfill(cbmp, 16*t_dright+8, 7, 16*t_dright+15, 8, c_inner);
20451 //t_vert
20452 rectfill(cbmp, 16*t_vert+4, 0, 16*t_vert+11, 15, c_outter);
20453 rectfill(cbmp, 16*t_vert+6, 0, 16*t_vert+9, 15, c_middle);
20454 rectfill(cbmp, 16*t_vert+7, 0, 16*t_vert+8, 15, c_inner);
20455 //t_horz
20456 rectfill(cbmp, 16*t_horz, 4, 16*t_horz+15, 11, c_outter);
20457 rectfill(cbmp, 16*t_horz, 6, 16*t_horz+15, 9, c_middle);
20458 rectfill(cbmp, 16*t_horz, 7, 16*t_horz+15, 8, c_inner);
20459 //t_notup
20460 rectfill(cbmp, 16*t_notup, 4, 16*t_notup+15, 11, c_outter);
20461 rectfill(cbmp, 16*t_notup+4, 8, 16*t_notup+11, 15, c_outter);
20462 rectfill(cbmp, 16*t_notup+6, 8, 16*t_notup+9, 15, c_middle);
20463 rectfill(cbmp, 16*t_notup, 6, 16*t_notup+15, 9, c_middle);
20464 rectfill(cbmp, 16*t_notup, 7, 16*t_notup+15, 8, c_inner);
20465 rectfill(cbmp, 16*t_notup+7, 8, 16*t_notup+8, 15, c_inner);
20466 //t_notdown
20467 rectfill(cbmp, 16*t_notdown, 4, 16*t_notdown+15, 11, c_outter);
20468 rectfill(cbmp, 16*t_notdown+4, 0, 16*t_notdown+11, 7, c_outter);
20469 rectfill(cbmp, 16*t_notdown+6, 0, 16*t_notdown+9, 7, c_middle);
20470 rectfill(cbmp, 16*t_notdown, 6, 16*t_notdown+15, 9, c_middle);
20471 rectfill(cbmp, 16*t_notdown, 7, 16*t_notdown+15, 8, c_inner);
20472 rectfill(cbmp, 16*t_notdown+7, 0, 16*t_notdown+8, 7, c_inner);
20473 //t_notleft
20474 rectfill(cbmp, 16*t_notleft+4, 0, 16*t_notleft+11, 15, c_outter);
20475 rectfill(cbmp, 16*t_notleft+8, 4, 16*t_notleft+15, 11, c_outter);
20476 rectfill(cbmp, 16*t_notleft+8, 6, 16*t_notleft+15, 9, c_middle);
20477 rectfill(cbmp, 16*t_notleft+6, 0, 16*t_notleft+9, 15, c_middle);
20478 rectfill(cbmp, 16*t_notleft+7, 0, 16*t_notleft+8, 15, c_inner);
20479 rectfill(cbmp, 16*t_notleft+8, 7, 16*t_notleft+15, 8, c_inner);
20480 //t_notright
20481 rectfill(cbmp, 16*t_notright+4, 0, 16*t_notright+11, 15, c_outter);
20482 rectfill(cbmp, 16*t_notright, 4, 16*t_notright+7, 11, c_outter);
20483 rectfill(cbmp, 16*t_notright, 6, 16*t_notright+7, 9, c_middle);
20484 rectfill(cbmp, 16*t_notright+6, 0, 16*t_notright+9, 15, c_middle);
20485 rectfill(cbmp, 16*t_notright+7, 0, 16*t_notright+8, 15, c_inner);
20486 rectfill(cbmp, 16*t_notright, 7, 16*t_notright+7, 8, c_inner);
20487 //t_all
20488 rectfill(cbmp, 16*t_all+4, 0, 16*t_all+11, 15, c_outter);
20489 rectfill(cbmp, 16*t_all, 4, 16*t_all+15, 11, c_outter);
20490 rectfill(cbmp, 16*t_all, 6, 16*t_all+15, 9, c_middle);
20491 rectfill(cbmp, 16*t_all+6, 0, 16*t_all+9, 15, c_middle);
20492 rectfill(cbmp, 16*t_all+7, 0, 16*t_all+8, 15, c_inner);
20493 rectfill(cbmp, 16*t_all, 7, 16*t_all+15, 8, c_inner);
20494 }
20495 //}
20496 //
20497
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 217184 times.
218418 for(size_t pos = 0; pos < 176; ++pos)
20498 {
20499 217184 int32_t offs = -1;
20500
8/17
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1207 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 511 times.
✓ Branch 7 taken 11477 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 37 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 82 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
217184 switch(grid[pos]>>1)
20501 {
20502 203837 case 0: default:
20503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203837 times.
203837 if(grid[pos])
20504 {
20505 offs = t_gr;
20506 break;
20507 }
20508 203837 continue; //no draw this pos
20509 case 0b0001:
20510 6 offs = t_up;
20511 6 break;
20512 case 0b0010:
20513 offs = t_down;
20514 break;
20515 case 0b0100:
20516 1207 offs = t_left;
20517 1207 break;
20518 case 0b1000:
20519 27 offs = t_right;
20520 27 break;
20521 case 0b0011:
20522 511 offs = t_vert;
20523 511 break;
20524 case 0b1100:
20525 11477 offs = t_horz;
20526 11477 break;
20527 case 0b0101:
20528 offs = t_uleft;
20529 break;
20530 case 0b1001:
20531 37 offs = t_uright;
20532 37 break;
20533 case 0b0110:
20534 offs = t_dleft;
20535 break;
20536 case 0b1010:
20537 82 offs = t_dright;
20538 82 break;
20539 case 0b1110:
20540 offs = t_notup;
20541 break;
20542 case 0b1101:
20543 offs = t_notdown;
20544 break;
20545 case 0b1011:
20546 offs = t_notleft;
20547 break;
20548 case 0b0111:
20549 offs = t_notright;
20550 break;
20551 case 0b1111:
20552 offs = t_all;
20553 break;
20554 }
20555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13347 times.
13347 if(id > 0) //tile
20556 {
20557 //Draw 'tile' at 'pos'
20558
3/6
✓ Branch 0 taken 13347 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13347 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13347 times.
✗ Branch 5 not taken.
13347 overtile16(lightbeam_bmp, tile+offs, COMBOX(pos), COMBOY(pos), cs, 0);
20559 13347 }
20560 else //colors
20561 {
20562 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, COMBOX(pos), COMBOY(pos), 16, 16);
20563 }
20564 13347 }
20565 //
20566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1234 if(cbmp) destroy_bitmap(cbmp);
20567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 delete[] it->second;
20568
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 it = maps.erase(it);
20569 }
20570 //Check triggers
20571 5152186 bool hastrigs = false, istrigged = true;
20572
1/2
✓ Branch 0 taken 5152186 times.
✗ Branch 1 not taken.
5152186 bool alltrig = getmapflag(mLIGHTBEAM);
20573
2/2
✓ Branch 0 taken 36065302 times.
✓ Branch 1 taken 5152186 times.
41217488 for(size_t layer = 0; layer < 7; ++layer)
20574 {
20575 36065302 mapscr* curlayer = FFCore.tempScreens[layer];
20576
2/2
✓ Branch 0 taken 6347493152 times.
✓ Branch 1 taken 36065302 times.
6383558454 for(size_t pos = 0; pos < 176; ++pos)
20577 {
20578 6347493152 newcombo const* cmb = &combobuf[curlayer->data[pos]];
20579
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 6347491918 times.
6347493152 if(cmb->type == cLIGHTTARGET)
20580 {
20581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20582 1234 hastrigs = true;
20583 1234 bool trigged = (istrig[pos]&trigflag);
20584
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
20585 trigged = !trigged;
20586
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 985 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
20587 {
20588
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
20589 {
20590 curlayer->data[pos] -= 1;
20591 istrigged = false;
20592 }
20593 249 }
20594 else //Unsolved version
20595 {
20596
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
20597 1 curlayer->data[pos] += 1;
20598 984 else istrigged = false;
20599 }
20600 1234 }
20601
2/2
✓ Branch 0 taken 6347488216 times.
✓ Branch 1 taken 3702 times.
6347491918 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20602 {
20603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20604 3702 bool trigged = (istrig[pos]&trigflag);
20605
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 3597 times.
✓ Branch 2 taken 3696 times.
✓ Branch 3 taken 6 times.
3702 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20606 3597 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20607 {
20608
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 do_trigger_combo(layer, pos);
20609 6 }
20610 3702 }
20611 6347493152 }
20612 36065302 }
20613
1/2
✓ Branch 0 taken 5152186 times.
✗ Branch 1 not taken.
5152186 word c = tmpscr->numFFC();
20614
2/2
✓ Branch 0 taken 5152186 times.
✓ Branch 1 taken 160734277 times.
165886463 for(word i=0; i<c; i++)
20615 {
20616 160734277 ffcdata& ffc = tmpscr->ffcs[i];
20617
1/2
✓ Branch 0 taken 160734277 times.
✗ Branch 1 not taken.
160734277 newcombo const* cmb = &combobuf[ffc.getData()];
20618
7/14
✓ Branch 0 taken 160734277 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160734277 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 160734277 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 160734277 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 160734277 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 160734277 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 160734277 times.
✗ Branch 13 not taken.
160734277 size_t pos = COMBOPOS(ffc.x+8, ffc.y+8);
20619
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 160733043 times.
160734277 if(cmb->type == cLIGHTTARGET)
20620 {
20621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb->attribytes[4] ? (1 << (cmb->attribytes[4]-1)) : ~0;
20622 1234 hastrigs = true;
20623 1234 bool trigged = (istrig[pos]&trigflag);
20624
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb->usrflags&cflag2) //Invert
20625 trigged = !trigged;
20626
2/2
✓ Branch 0 taken 985 times.
✓ Branch 1 taken 249 times.
1234 if(cmb->usrflags&cflag1) //Solved Version
20627 {
20628
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
20629 {
20630 ffc.incData(-1);
20631 istrigged = false;
20632 }
20633 249 }
20634 else //Unsolved version
20635 {
20636
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
20637
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 ffc.incData(1);
20638 984 else istrigged = false;
20639 }
20640 1234 }
20641
2/2
✓ Branch 0 taken 160730575 times.
✓ Branch 1 taken 2468 times.
160733043 else if(cmb->triggerflags[1] & (combotriggerLIGHTON|combotriggerLIGHTOFF))
20642 {
20643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2468 times.
2468 int32_t trigflag = cmb->triglbeam ? (1 << (cmb->triglbeam-1)) : ~0;
20644 2468 bool trigged = (istrig[pos]&trigflag);
20645
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2406 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 2464 times.
2468 if(trigged ? (cmb->triggerflags[1] & combotriggerLIGHTON)
20646 2406 : (cmb->triggerflags[1] & combotriggerLIGHTOFF))
20647 {
20648
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 do_trigger_combo_ffc(i);
20649 4 }
20650 2468 }
20651 160734277 }
20652
6/6
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 5150952 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 984 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 249 times.
5152186 if(hastrigs && istrigged && !alltrig)
20653 {
20654
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 hidden_entrance(0,true,false,-7);
20655
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 sfx(tmpscr->secretsfx);
20656
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(tmpscr->flags5&fTEMPSECRETS))
20657 {
20658
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mSECRET);
20659
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag(mLIGHTBEAM);
20660 1 }
20661 1 }
20662 5152186 }
20663
20664 5145819 void HeroClass::checktouchblk()
20665 {
20666
2/2
✓ Branch 0 taken 13406 times.
✓ Branch 1 taken 5132413 times.
5145819 if(toogam) return;
20667
20668
2/2
✓ Branch 0 taken 341338 times.
✓ Branch 1 taken 4791075 times.
5132413 if(!pushing)
20669 4791075 return;
20670
20671 341338 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
20672
20673
4/4
✓ Branch 0 taken 341158 times.
✓ Branch 1 taken 180 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 341062 times.
341338 if(charging > 0 || spins > 0) //if not I probably will at some point...
20674 {
20675
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 if(Up()&&Left())tdir = (charging%2)*2;
20676
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 270 times.
✗ Branch 3 not taken.
276 else if(Up()&&Right())tdir = (charging%2)*3;
20677
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Left())tdir = 1+(charging%2)*1;
20678
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 else if(Down()&&Right())tdir = 1+(charging%2)*2;
20679 else
20680 {
20681
2/2
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 6 times.
276 if(Up())tdir=0;
20682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(Down())tdir=1;
20683
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(Left())tdir=2;
20684 else if(Right())tdir=3;
20685 }
20686 276 }
20687
20688 341338 int32_t tx=0,ty=-1;
20689
20690
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 87925 times.
✓ Branch 2 taken 72393 times.
✓ Branch 3 taken 87860 times.
✓ Branch 4 taken 93160 times.
341338 switch(tdir)
20691 {
20692 case up:
20693
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 87885 times.
87925 if(touchcombo(x,y+(bigHitbox?0:7)))
20694 {
20695 40 tx=x;
20696 40 ty=y+(bigHitbox?0:7);
20697 40 }
20698
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 87864 times.
87885 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
20699 {
20700 21 tx=x+8;
20701 21 ty=y+(bigHitbox?0:7);
20702 21 }
20703
20704 87925 break;
20705
20706 case down:
20707
2/2
✓ Branch 0 taken 1283 times.
✓ Branch 1 taken 71110 times.
72393 if(touchcombo(x,y+16))
20708 {
20709 1283 tx=x;
20710 1283 ty=y+16;
20711 1283 }
20712
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 70873 times.
71110 else if(touchcombo(x+8,y+16))
20713 {
20714 237 tx=x+8;
20715 237 ty=y+16;
20716 237 }
20717
20718 72393 break;
20719
20720 case left:
20721
2/2
✓ Branch 0 taken 87231 times.
✓ Branch 1 taken 629 times.
87860 if(touchcombo(x-1,y+15))
20722 {
20723 629 tx=x-1;
20724 629 ty=y+15;
20725 629 }
20726
20727 87860 break;
20728
20729 case right:
20730
2/2
✓ Branch 0 taken 92142 times.
✓ Branch 1 taken 1018 times.
93160 if(touchcombo(x+16,y+15))
20731 {
20732 1018 tx=x+16;
20733 1018 ty=y+15;
20734 1018 }
20735
20736 93160 break;
20737 }
20738
20739
2/2
✓ Branch 0 taken 338110 times.
✓ Branch 1 taken 3228 times.
341338 if(ty>=0)
20740 {
20741 3228 ty&=0xF0;
20742 3228 tx&=0xF0;
20743 3228 int32_t di = ty+(tx>>4);
20744
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3228 if((getAction() != hopping || isSideViewHero()))
20745 {
20746 3228 trigger_armos_grave(0, di, dir);
20747 3228 }
20748 3228 }
20749 5145819 }
20750
20751 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
20752 {
20753 switch(cdir)
20754 {
20755 case up:
20756 cy-=16;
20757 break;
20758
20759 case down:
20760 cy+=16;
20761 break;
20762
20763 case left:
20764 cx-=16;
20765 break;
20766
20767 case right:
20768 cx+=16;
20769 break;
20770 }
20771
20772 // off the screen
20773 if(cx<0 || cy<0 || cx>255 || cy>175)
20774 {
20775 int32_t ns = nextscr(cdir);
20776
20777 if(ns==0xFFFF) return 0;
20778
20779 // want actual screen index, not game->maps[] index
20780 ns = (ns&127) + (ns>>7)*MAPSCRS;
20781
20782 switch(cdir)
20783 {
20784 case up:
20785 cy=160;
20786 break;
20787
20788 case down:
20789 cy=0;
20790 break;
20791
20792 case left:
20793 cx=240;
20794 break;
20795
20796 case right:
20797 cx=0;
20798 break;
20799 }
20800
20801 // from MAPCOMBO()
20802 int32_t cmb = (cy&0xF0)+(cx>>4);
20803
20804 if(cmb>175)
20805 return 0;
20806
20807 return TheMaps[ns].data[cmb]; // entire combo code
20808 }
20809
20810 return MAPCOMBO(cx,cy);
20811 }
20812
20813 7733 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
20814 {
20815
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1567 times.
✓ Branch 2 taken 1737 times.
✓ Branch 3 taken 2292 times.
✓ Branch 4 taken 2137 times.
7733 switch(cdir)
20816 {
20817 case up:
20818 1567 cy-=16;
20819 1567 break;
20820
20821 case down:
20822 1737 cy+=16;
20823 1737 break;
20824
20825 case left:
20826 2292 cx-=16;
20827 2292 break;
20828
20829 case right:
20830 2137 cx+=16;
20831 2137 break;
20832 }
20833
20834 // off the screen
20835
8/8
✓ Branch 0 taken 7689 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 7632 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 7521 times.
✓ Branch 5 taken 111 times.
✓ Branch 6 taken 101 times.
✓ Branch 7 taken 7420 times.
7733 if(cx<0 || cy<0 || cx>255 || cy>175)
20836 {
20837 313 int32_t ns = nextscr(cdir);
20838
20839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 313 times.
313 if(ns==0xFFFF) return 0;
20840
20841 // want actual screen index, not game->maps[] index
20842 313 ns = (ns&127) + (ns>>7)*MAPSCRS;
20843
20844
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 111 times.
313 switch(cdir)
20845 {
20846 case up:
20847 57 cy=160;
20848 57 break;
20849
20850 case down:
20851 101 cy=0;
20852 101 break;
20853
20854 case left:
20855 44 cx=240;
20856 44 break;
20857
20858 case right:
20859 111 cx=0;
20860 111 break;
20861 }
20862
20863 // from MAPCOMBO()
20864 313 int32_t cmb = (cy&0xF0)+(cx>>4);
20865
20866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 313 times.
313 if(cmb>175)
20867 return 0;
20868
20869
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 248 times.
313 if(!comboflag)
20870 {
20871 248 return TheMaps[ns].sflag[cmb]; // flag
20872 }
20873 else
20874 {
20875 65 return combobuf[TheMaps[ns].data[cmb]].flag; // flag
20876 }
20877 }
20878
20879
2/2
✓ Branch 0 taken 1753 times.
✓ Branch 1 taken 5667 times.
7420 if(comboflag)
20880 {
20881 1753 return MAPCOMBOFLAG(cx,cy);
20882 }
20883
20884 5667 return MAPFLAG(cx,cy);
20885 7733 }
20886
20887 bool did_secret;
20888
20889 5145819 void HeroClass::checkspecial()
20890 {
20891 5145819 checktouchblk();
20892
20893 5145819 bool hasmainguy = hasMainGuy(); // calculate it once
20894
20895
4/4
✓ Branch 0 taken 5086005 times.
✓ Branch 1 taken 59814 times.
✓ Branch 2 taken 3230958 times.
✓ Branch 3 taken 1855047 times.
5145819 if(!(loaded_enemies && !hasmainguy))
20896 3290772 did_secret=false;
20897 else
20898 {
20899 // after beating enemies
20900
20901 // item
20902
2/2
✓ Branch 0 taken 1854697 times.
✓ Branch 1 taken 350 times.
1855047 if(hasitem&(4|2|1))
20903 {
20904 350 int32_t Item=tmpscr->item;
20905
20906 //if(getmapflag())
20907 // Item=0;
20908
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 350 times.
350 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
20909 {
20910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if(hasitem==1)
20911 350 sfx(WAV_CLEARED);
20912
20913
2/4
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 350 times.
✗ Branch 3 not taken.
700 items.add(new item((zfix)tmpscr->itemx,
20914
6/12
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 350 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 350 times.
✗ Branch 11 not taken.
350 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
20915
6/10
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 324 times.
✗ Branch 9 not taken.
350 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
20916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
20917 350 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
20918 350 }
20919
20920 350 hasitem &= ~ (4|2|1);
20921 350 }
20922
20923 // generic 'Enemies->' trigger
20924
2/2
✓ Branch 0 taken 12985329 times.
✓ Branch 1 taken 1855047 times.
14840376 for(auto lyr = 0; lyr < 7; ++lyr)
20925 {
20926
2/2
✓ Branch 0 taken 2285417904 times.
✓ Branch 1 taken 12985329 times.
2298403233 for(auto pos = 0; pos < 176; ++pos)
20927 {
20928 2285417904 newcombo const& cmb = combobuf[FFCore.tempScreens[lyr]->data[pos]];
20929
2/2
✓ Branch 0 taken 2285417901 times.
✓ Branch 1 taken 3 times.
2285417904 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20930 {
20931 3 do_trigger_combo(lyr,pos);
20932 3 }
20933 2285417904 }
20934 12985329 }
20935 1855047 word c = tmpscr->numFFC();
20936
2/2
✓ Branch 0 taken 56445783 times.
✓ Branch 1 taken 1855047 times.
58300830 for(word i=0; i<c; i++)
20937 {
20938 56445783 ffcdata& ffc = tmpscr->ffcs[i];
20939 56445783 newcombo const& cmb = combobuf[ffc.getData()];
20940
1/2
✓ Branch 0 taken 56445783 times.
✗ Branch 1 not taken.
56445783 if(cmb.triggerflags[2] & combotriggerKILLENEMIES)
20941 {
20942 do_trigger_combo_ffc(i);
20943 }
20944 56445783 }
20945
1/2
✓ Branch 0 taken 1855047 times.
✗ Branch 1 not taken.
1855047 if(tmpscr->flags9 & fENEMY_WAVES)
20946 {
20947 hasmainguy = hasMainGuy(); //possibly un-beat the enemies (another 'wave'?)
20948 }
20949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1855047 times.
1855047 if(!hasmainguy)
20950 {
20951 // if room has traps, guys don't come back
20952
2/2
✓ Branch 0 taken 949784064 times.
✓ Branch 1 taken 1855047 times.
951639111 for(int32_t i=0; i<eMAXGUYS; i++)
20953 {
20954
4/4
✓ Branch 0 taken 27567107 times.
✓ Branch 1 taken 922216957 times.
✓ Branch 2 taken 3653492 times.
✓ Branch 3 taken 23913615 times.
949784064 if(guysbuf[i].family==eeTRAP&&guysbuf[i].misc2)
20955
4/4
✓ Branch 0 taken 14854 times.
✓ Branch 1 taken 3638638 times.
✓ Branch 2 taken 14832 times.
✓ Branch 3 taken 22 times.
3653514 if(guys.idCount(i) && !getmapflag(mTMPNORET))
20956 22 setmapflag(mTMPNORET);
20957 949784064 }
20958 // clear enemies and open secret
20959
4/4
✓ Branch 0 taken 1743073 times.
✓ Branch 1 taken 111974 times.
✓ Branch 2 taken 1742649 times.
✓ Branch 3 taken 424 times.
1855047 if(!did_secret && (tmpscr->flags2&fCLEARSECRET))
20960 {
20961 424 bool only16_31 = get_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
20962 424 hidden_entrance(0,true,only16_31,-2);
20963
20964
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 19 times.
424 if(tmpscr->flags4&fENEMYSCRTPERM && canPermSecret())
20965 {
20966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
20967 19 }
20968
20969 424 sfx(tmpscr->secretsfx);
20970 424 did_secret=true;
20971 424 }
20972 1855047 }
20973 }
20974
20975 // doors
20976
2/2
✓ Branch 0 taken 3875820 times.
✓ Branch 1 taken 18249097 times.
22124917 for(int32_t i=0; i<4; i++)
20977
2/2
✓ Branch 0 taken 16979098 times.
✓ Branch 1 taken 1269999 times.
18249097 if(tmpscr->door[i]==dSHUTTER)
20978 {
20979
4/4
✓ Branch 0 taken 1245700 times.
✓ Branch 1 taken 24299 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 1244938 times.
1269999 if(opendoors==0 && loaded_enemies)
20980 {
20981
4/4
✓ Branch 0 taken 1060776 times.
✓ Branch 1 taken 184162 times.
✓ Branch 2 taken 1059312 times.
✓ Branch 3 taken 1464 times.
1244938 if(!(tmpscr->flags&fSHUTTERS) && !hasmainguy)
20982 1464 opendoors=12;
20983 1244938 }
20984
2/2
✓ Branch 0 taken 19846 times.
✓ Branch 1 taken 5215 times.
25061 else if(opendoors<0)
20985 5215 ++opendoors;
20986
2/2
✓ Branch 0 taken 18192 times.
✓ Branch 1 taken 1654 times.
19846 else if((--opendoors)==0)
20987 1654 openshutters();
20988
20989 1269999 break;
20990 }
20991
20992 // set boss flag when boss is gone
20993
6/6
✓ Branch 0 taken 5086005 times.
✓ Branch 1 taken 59814 times.
✓ Branch 2 taken 82884 times.
✓ Branch 3 taken 5003121 times.
✓ Branch 4 taken 64872 times.
✓ Branch 5 taken 18012 times.
5145819 if(loaded_enemies && tmpscr->enemyflags&efBOSS && !hasmainguy)
20994 {
20995 18012 game->lvlitems[dlevel]|=liBOSS;
20996 18012 stop_sfx(tmpscr->bosssfx);
20997 18012 }
20998
20999
2/2
✓ Branch 0 taken 5133303 times.
✓ Branch 1 taken 12516 times.
5145819 if(getmapflag(mCHEST)) // if special stuff done before
21000 {
21001 12516 remove_chests((currscr>=128)?1:0);
21002 12516 }
21003
21004
1/2
✓ Branch 0 taken 5145819 times.
✗ Branch 1 not taken.
5145819 if(getmapflag(mLOCKEDCHEST)) // if special stuff done before
21005 {
21006 remove_lockedchests((currscr>=128)?1:0);
21007 }
21008
21009
1/2
✓ Branch 0 taken 5145819 times.
✗ Branch 1 not taken.
5145819 if(getmapflag(mBOSSCHEST)) // if special stuff done before
21010 {
21011 remove_bosschests((currscr>=128)?1:0);
21012 }
21013
21014 5145819 clear_xstatecombos((currscr>=128)?1:0);
21015
21016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5145819 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5145819 if((hasitem&8) && triggered_screen_secrets)
21017 {
21018 int32_t Item=tmpscr->item;
21019
21020 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21021 {
21022 items.add(new item((zfix)tmpscr->itemx,
21023 (tmpscr->flags7&fITEMFALLS && isSideViewHero()) ? (zfix)-170 : (zfix)tmpscr->itemy+1,
21024 (tmpscr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
21025 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
21026 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21027 }
21028
21029 hasitem &= ~8;
21030 }
21031 5145819 }
21032
21033 //Gets the 4 comboposes indicated by the coordinates, replacing duplicates with '-1'
21034 3637400 void getPoses(int32_t* poses, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
21035 {
21036 int32_t tmp;
21037 3637400 poses[0] = COMBOPOS(x1,y1);
21038
21039 3637400 tmp = COMBOPOS(x1,y2);
21040
2/2
✓ Branch 0 taken 2884055 times.
✓ Branch 1 taken 753345 times.
3637400 if(tmp == poses[0])
21041 2884055 poses[1] = -1;
21042 753345 else poses[1] = tmp;
21043
21044 3637400 tmp = COMBOPOS(x2,y1);
21045
3/4
✓ Branch 0 taken 1662638 times.
✓ Branch 1 taken 1974762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1662638 times.
3637400 if(tmp == poses[0] || tmp == poses[1])
21046 1974762 poses[2] = -1;
21047 1662638 else poses[2] = tmp;
21048
21049 3637400 tmp = COMBOPOS(x2,y2);
21050
6/6
✓ Branch 0 taken 2104016 times.
✓ Branch 1 taken 1533384 times.
✓ Branch 2 taken 1662638 times.
✓ Branch 3 taken 441378 times.
✓ Branch 4 taken 1350671 times.
✓ Branch 5 taken 311967 times.
3637400 if(tmp == poses[0] || tmp == poses[1] || tmp == poses[2])
21051 3325433 poses[3] = -1;
21052 311967 else poses[3] = tmp;
21053 3637400 }
21054
21055 5144105 void HeroClass::checkspecial2(int32_t *ls)
21056 {
21057
4/6
✓ Branch 0 taken 4486302 times.
✓ Branch 1 taken 657803 times.
✓ Branch 2 taken 4486302 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4486302 times.
5144105 if(get_bit(quest_rules,qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
21058 {
21059 // Must run fairycircle stuff if currently active, otherwise hero gets stuck!
21060
2/2
✓ Branch 0 taken 14344 times.
✓ Branch 1 taken 4471958 times.
4486302 if (!fairyclk)
21061 {
21062
2/2
✓ Branch 0 taken 1298684 times.
✓ Branch 1 taken 3173274 times.
4471958 if(y.getInt()&7)
21063 1298684 return;
21064
21065
2/2
✓ Branch 0 taken 1769987 times.
✓ Branch 1 taken 1403287 times.
3173274 if(x.getInt()&7)
21066 1769987 return;
21067 1403287 }
21068 1417631 }
21069
21070
2/2
✓ Branch 0 taken 4512 times.
✓ Branch 1 taken 2070922 times.
2075434 if(toogam) return;
21071
21072 2070922 bool didstrig = false;
21073
21074
2/2
✓ Branch 0 taken 4141509 times.
✓ Branch 1 taken 2070919 times.
6212428 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
21075 {
21076
4/4
✓ Branch 0 taken 8283018 times.
✓ Branch 1 taken 4141506 times.
✓ Branch 2 taken 16566033 times.
✓ Branch 3 taken 8283015 times.
28990554 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
21077 {
21078
2/2
✓ Branch 0 taken 8283015 times.
✓ Branch 1 taken 8283018 times.
16566033 newcombo const& cmb = combobuf[k>0 ? MAPFFCOMBO(x+j,y+i) : MAPCOMBO(x+j,y+i)];
21079 16566033 int32_t stype = cmb.type;
21080 16566033 int32_t warpsound = cmb.attribytes[0];
21081
2/2
✓ Branch 0 taken 16565831 times.
✓ Branch 1 taken 202 times.
16566033 if(cmb.triggerflags[0] & combotriggerONLYGENTRIG)
21082 202 stype = cNONE;
21083
2/2
✓ Branch 0 taken 16566030 times.
✓ Branch 1 taken 3 times.
16566033 if(stype==cSWARPA)
21084 {
21085
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(tmpscr->flags5&fDIRECTSWARP)
21086 {
21087 didpit=true;
21088 pitx=x;
21089 pity=y;
21090 }
21091
21092 3 sdir=dir;
21093 3 dowarp(0,0,warpsound);
21094 3 return;
21095 }
21096
21097
1/2
✓ Branch 0 taken 16566030 times.
✗ Branch 1 not taken.
16566030 if(stype==cSWARPB)
21098 {
21099 if(tmpscr->flags5&fDIRECTSWARP)
21100 {
21101 didpit=true;
21102 pitx=x;
21103 pity=y;
21104 }
21105
21106 sdir=dir;
21107 dowarp(0,1,warpsound);
21108 return;
21109 }
21110
21111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16566030 times.
16566030 if(stype==cSWARPC)
21112 {
21113 if(tmpscr->flags5&fDIRECTSWARP)
21114 {
21115 didpit=true;
21116 pitx=x;
21117 pity=y;
21118 }
21119
21120 sdir=dir;
21121 dowarp(0,2,warpsound);
21122 return;
21123 }
21124
21125
1/2
✓ Branch 0 taken 16566030 times.
✗ Branch 1 not taken.
16566030 if(stype==cSWARPD)
21126 {
21127 if(tmpscr->flags5&fDIRECTSWARP)
21128 {
21129 didpit=true;
21130 pitx=x;
21131 pity=y;
21132 }
21133
21134 sdir=dir;
21135 dowarp(0,3,warpsound);
21136 return;
21137 }
21138
21139
1/2
✓ Branch 0 taken 16566030 times.
✗ Branch 1 not taken.
16566030 if(stype==cSWARPR)
21140 {
21141 if(tmpscr->flags5&fDIRECTSWARP)
21142 {
21143 didpit=true;
21144 pitx=x;
21145 pity=y;
21146 }
21147
21148 sdir=dir;
21149 dowarp(0,(zc_oldrand()%4),warpsound);
21150 return;
21151 }
21152
21153 16566030 int32_t pos = COMBOPOS(x+j, y+i);
21154
4/4
✓ Branch 0 taken 16563874 times.
✓ Branch 1 taken 2156 times.
✓ Branch 2 taken 16565320 times.
✓ Branch 3 taken 710 times.
16566030 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=pos)
21155 {
21156 // zprint("Step Secs\n");
21157
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
710 if(stype==cSTRIGFLAG && canPermSecret())
21158 {
21159 if(!didstrig)
21160 {
21161 stepsecret = pos;
21162
21163 if(!(tmpscr->flags5&fTEMPSECRETS))
21164 {
21165 setmapflag(mSECRET);
21166 }
21167 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
21168 //zprint("Step Secrets SFX: %d\n", thesfx);
21169 sfx(warpsound,pan((int32_t)x));
21170 hidden_entrance(0,true,false);
21171 didstrig = true;
21172 }
21173 }
21174 else
21175 {
21176
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 345 times.
710 if(!didstrig)
21177 {
21178 345 stepsecret = pos;
21179 345 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21180 345 hidden_entrance(0,true,only16_31);
21181 345 didstrig = true;
21182 //play trigger sound
21183 //int32_t thesfx = combobuf[MAPCOMBO(x+j,y+i)].attribytes[0];
21184 //zprint("Step Secrets SFX: %d\n", thesfx);
21185 //sfx(thesfx,pan((int32_t)x));
21186 345 sfx(warpsound,pan((int32_t)x));
21187 345 }
21188 }
21189 710 }
21190 24849045 }
21191 4141506 }
21192
21193 2070919 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
21194
21195 // check if he's standing on a warp he just came out of
21196 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
21197
2/2
✓ Branch 0 taken 496445 times.
✓ Branch 1 taken 1574474 times.
2070919 if (!get_bit(quest_rules,qr_210_WARPRETURN))
21198 {
21199
6/6
✓ Branch 0 taken 1573152 times.
✓ Branch 1 taken 1322 times.
✓ Branch 2 taken 175603 times.
✓ Branch 3 taken 1397549 times.
✓ Branch 4 taken 14545 times.
✓ Branch 5 taken 161058 times.
1574474 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
21200 {
21201
5/6
✓ Branch 0 taken 160438 times.
✓ Branch 1 taken 620 times.
✓ Branch 2 taken 159453 times.
✓ Branch 3 taken 985 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 159453 times.
161058 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
21202 {
21203
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 159448 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
159453 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21204 159453 else return;
21205 }
21206 1605 }
21207 1415021 }
21208 else
21209 {
21210
2/2
✓ Branch 0 taken 418182 times.
✓ Branch 1 taken 78263 times.
496445 if((int(y)&0xF8)==warpy)
21211 {
21212
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 77507 times.
78263 if(x==warpx)
21213 {
21214
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
77507 if (get_bit(quest_rules, qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
21215 77507 else return;
21216 }
21217 756 }
21218 }
21219
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 1833793 times.
1833959 if (!RaftPass) warpy=-1;
21220
21221
6/6
✓ Branch 0 taken 1831042 times.
✓ Branch 1 taken 2585 times.
✓ Branch 2 taken 112364 times.
✓ Branch 3 taken 1718678 times.
✓ Branch 4 taken 87668 times.
✓ Branch 5 taken 24696 times.
1833959 if(((int32_t)y<raftwarpy-(get_bit(quest_rules, qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_bit(quest_rules, qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
21222 {
21223 1745959 raftwarpy = -1;
21224 1745959 }
21225
6/6
✓ Branch 0 taken 1831711 times.
✓ Branch 1 taken 1916 times.
✓ Branch 2 taken 104440 times.
✓ Branch 3 taken 1727271 times.
✓ Branch 4 taken 77819 times.
✓ Branch 5 taken 26621 times.
1833627 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
21226 {
21227 1755808 raftwarpx = -1;
21228 1755808 }
21229 1833627 int32_t tx=x;
21230 1833627 int32_t ty=y;
21231
21232 1833627 int32_t flag=0;
21233 1833627 int32_t flag2=0;
21234 1833627 int32_t flag3=0;
21235 1833627 int32_t type=0;
21236 1833627 int32_t water=0;
21237 1833627 int32_t index = 0;
21238
21239 1833627 bool setsave=false;
21240 1833627 int32_t warpsfx2 = 0;
21241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1833627 times.
1833627 if (RaftPass) goto RaftingStuff;
21242
21243 //bool gotpit=false;
21244
21245 int32_t x1,x2,y1,y2;
21246 1833627 x1 = tx;
21247 1833627 x2 = tx+15;
21248 1833627 y1 = ty;
21249 1833627 y2 = ty+15;
21250
21251
4/4
✓ Branch 0 taken 1210164 times.
✓ Branch 1 taken 623463 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 1210330 times.
1833627 if((diagonalMovement||NO_GRIDLOCK))
21252 {
21253 623629 x1 = tx+4;
21254 623629 x2 = tx+11;
21255 623629 y1 = ty+4;
21256 623629 y2 = ty+11;
21257 623629 }
21258
21259 int32_t types[4];
21260 1833959 types[0]=types[1]=types[2]=types[3]=-1;
21261 int32_t cids[4];
21262 int32_t ffcids[4];
21263 1833959 cids[0]=cids[1]=cids[2]=cids[3]=-1;
21264 1833959 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
21265 //
21266 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
21267 //
21268 1833959 types[0] = MAPFLAG(x1,y1);
21269 1833959 types[1] = MAPFLAG(x1,y2);
21270 1833959 types[2] = MAPFLAG(x2,y1);
21271 1833959 types[3] = MAPFLAG(x2,y2);
21272
21273
21274 //MAPFFCOMBO
21275
21276
21277
6/6
✓ Branch 0 taken 1793032 times.
✓ Branch 1 taken 40927 times.
✓ Branch 2 taken 1788320 times.
✓ Branch 3 taken 4712 times.
✓ Branch 4 taken 23946 times.
✓ Branch 5 taken 1764374 times.
1833959 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21278 1764374 flag = types[0];
21279
21280 // 2.10 compatibility...
21281
8/10
✓ Branch 0 taken 40966 times.
✓ Branch 1 taken 28619 times.
✓ Branch 2 taken 34741 times.
✓ Branch 3 taken 6225 times.
✓ Branch 4 taken 24456 times.
✓ Branch 5 taken 10285 times.
✓ Branch 6 taken 24456 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 24456 times.
69585 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
21282 10285 flag = types[0];
21283
21284
21285 1833959 types[0] = MAPCOMBOFLAG(x1,y1);
21286 1833959 types[1] = MAPCOMBOFLAG(x1,y2);
21287 1833959 types[2] = MAPCOMBOFLAG(x2,y1);
21288 1833959 types[3] = MAPCOMBOFLAG(x2,y2);
21289
21290
6/6
✓ Branch 0 taken 1832258 times.
✓ Branch 1 taken 1701 times.
✓ Branch 2 taken 1831909 times.
✓ Branch 3 taken 349 times.
✓ Branch 4 taken 472 times.
✓ Branch 5 taken 1831437 times.
1833959 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21291 1831437 flag2 = types[0];
21292
21293 1833959 types[0] = MAPFFCOMBOFLAG(x1,y1);
21294 1833959 types[1] = MAPFFCOMBOFLAG(x1,y2);
21295 1833959 types[2] = MAPFFCOMBOFLAG(x2,y1);
21296 1833959 types[3] = MAPFFCOMBOFLAG(x2,y2);
21297
21298
21299 //
21300
21301
6/6
✓ Branch 0 taken 1833787 times.
✓ Branch 1 taken 172 times.
✓ Branch 2 taken 1833777 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1833774 times.
1833959 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21302 1833774 flag3 = types[0];
21303
21304 //
21305 // Now, let's check for warp combos...
21306 //
21307
21308 //
21309
21310 1833959 cids[0] = MAPCOMBO(x1,y1);
21311 1833959 cids[1] = MAPCOMBO(x1,y2);
21312 1833959 cids[2] = MAPCOMBO(x2,y1);
21313 1833959 cids[3] = MAPCOMBO(x2,y2);
21314
21315 1833959 types[0] = COMBOTYPE(x1,y1);
21316
21317
2/2
✓ Branch 0 taken 1812455 times.
✓ Branch 1 taken 21504 times.
1833959 if(MAPFFCOMBO(x1,y1))
21318 {
21319 21504 types[0] = FFCOMBOTYPE(x1,y1);
21320 21504 cids[0] = MAPFFCOMBO(x1,y1);
21321 21504 }
21322
21323 1833959 types[1] = COMBOTYPE(x1,y2);
21324
21325
2/2
✓ Branch 0 taken 1817939 times.
✓ Branch 1 taken 16020 times.
1833959 if(MAPFFCOMBO(x1,y2))
21326 {
21327 16020 types[1] = FFCOMBOTYPE(x1,y2);
21328 16020 cids[1] = MAPFFCOMBO(x1,y2);
21329 16020 }
21330
21331 1833959 types[2] = COMBOTYPE(x2,y1);
21332
21333
2/2
✓ Branch 0 taken 1812336 times.
✓ Branch 1 taken 21623 times.
1833959 if(MAPFFCOMBO(x2,y1))
21334 {
21335 21623 types[2] = FFCOMBOTYPE(x2,y1);
21336 21623 cids[2] = MAPFFCOMBO(x2,y1);
21337 21623 }
21338 1833959 types[3] = COMBOTYPE(x2,y2);
21339
21340
2/2
✓ Branch 0 taken 1817801 times.
✓ Branch 1 taken 16158 times.
1833959 if(MAPFFCOMBO(x2,y2))
21341 {
21342 16158 types[3] = FFCOMBOTYPE(x2,y2);
21343 16158 cids[3] = MAPFFCOMBO(x2,y2);
21344 16158 }
21345 // Change B, C and D warps into A, for the comparison below...
21346
2/2
✓ Branch 0 taken 7335172 times.
✓ Branch 1 taken 1833959 times.
9169131 for(int32_t i=0; i<4; i++)
21347 {
21348
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 7334848 times.
7335172 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21349 {
21350 324 types[i] = cNONE;
21351 324 continue;
21352 }
21353
2/2
✓ Branch 0 taken 1598 times.
✓ Branch 1 taken 7333250 times.
7334848 if(types[i]==cCAVE)
21354 {
21355 1598 index=0;
21356 1598 warpsfx2 = combobuf[cids[i]].attribytes[0];
21357 1598 }
21358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7333250 times.
7333250 else if(types[i]==cCAVEB)
21359 {
21360 types[i]=cCAVE;
21361 index=1;
21362 warpsfx2 = combobuf[cids[i]].attribytes[0];
21363 }
21364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7333250 times.
7333250 else if(types[i]==cCAVEC)
21365 {
21366 types[i]=cCAVE;
21367 index=2;
21368 warpsfx2 = combobuf[cids[i]].attribytes[0];
21369 }
21370
1/2
✓ Branch 0 taken 7333250 times.
✗ Branch 1 not taken.
7333250 else if(types[i]==cCAVED)
21371 {
21372 types[i]=cCAVE;
21373 index=3;
21374 warpsfx2 = combobuf[cids[i]].attribytes[0];
21375 }
21376
21377
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 7334653 times.
7334848 if(types[i]==cPIT)
21378 {
21379 195 index=0;
21380 195 warpsfx2 = combobuf[cids[i]].attribytes[0];
21381 195 }
21382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334653 times.
7334653 else if(types[i]==cPITB)
21383 {
21384 types[i]=cPIT;
21385 warpsfx2 = combobuf[cids[i]].attribytes[0];
21386 index=1;
21387 }
21388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334653 times.
7334653 else if(types[i]==cPITC)
21389 {
21390 types[i]=cPIT;
21391 warpsfx2 = combobuf[cids[i]].attribytes[0];
21392 index=2;
21393 }
21394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334653 times.
7334653 else if(types[i]==cPITD)
21395 {
21396 types[i]=cPIT;
21397 warpsfx2 = combobuf[cids[i]].attribytes[0];
21398 index=3;
21399 }
21400
1/2
✓ Branch 0 taken 7334653 times.
✗ Branch 1 not taken.
7334653 else if(types[i]==cPITR)
21401 {
21402 types[i]=cPIT;
21403 warpsfx2 = combobuf[cids[i]].attribytes[0];
21404 index=zc_oldrand()%4;
21405 }
21406
21407
2/2
✓ Branch 0 taken 9522 times.
✓ Branch 1 taken 7325326 times.
7334848 if(types[i]==cSTAIR)
21408 {
21409 9522 index=0;
21410 9522 warpsfx2 = combobuf[cids[i]].attribytes[0];
21411 9522 }
21412
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 7325226 times.
7325326 else if(types[i]==cSTAIRB)
21413 {
21414 100 types[i]=cSTAIR;
21415 100 warpsfx2 = combobuf[cids[i]].attribytes[0];
21416 100 index=1;
21417 100 }
21418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325226 times.
7325226 else if(types[i]==cSTAIRC)
21419 {
21420 types[i]=cSTAIR;
21421 warpsfx2 = combobuf[cids[i]].attribytes[0];
21422 index=2;
21423 }
21424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7325226 times.
7325226 else if(types[i]==cSTAIRD)
21425 {
21426 types[i]=cSTAIR;
21427 warpsfx2 = combobuf[cids[i]].attribytes[0];
21428 index=3;
21429 }
21430
1/2
✓ Branch 0 taken 7325226 times.
✗ Branch 1 not taken.
7325226 else if(types[i]==cSTAIRR)
21431 {
21432 types[i]=cSTAIR;
21433 index=zc_oldrand()%4;
21434 warpsfx2 = combobuf[cids[i]].attribytes[0];
21435 }
21436
21437
2/2
✓ Branch 0 taken 1203 times.
✓ Branch 1 taken 7333645 times.
7334848 if(types[i]==cCAVE2)
21438 {
21439 1203 index=0;
21440 1203 warpsfx2 = combobuf[cids[i]].attribytes[0];
21441 1203 }
21442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7333645 times.
7333645 else if(types[i]==cCAVE2B)
21443 {
21444 types[i]=cCAVE2;
21445 index=1;
21446 warpsfx2 = combobuf[cids[i]].attribytes[0];
21447 }
21448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7333645 times.
7333645 else if(types[i]==cCAVE2C)
21449 {
21450 types[i]=cCAVE2;
21451 warpsfx2 = combobuf[cids[i]].attribytes[0];
21452 index=2;
21453 }
21454
1/2
✓ Branch 0 taken 7333645 times.
✗ Branch 1 not taken.
7333645 else if(types[i]==cCAVE2D)
21455 {
21456 types[i]=cCAVE2;
21457 warpsfx2 = combobuf[cids[i]].attribytes[0];
21458 index=3;
21459 }
21460
21461
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 7334772 times.
7334848 if(types[i]==cSWIMWARP)
21462 {
21463 76 index=0;
21464 76 warpsfx2 = combobuf[cids[i]].attribytes[0];
21465 76 }
21466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334772 times.
7334772 else if(types[i]==cSWIMWARPB)
21467 {
21468 types[i]=cSWIMWARP;
21469 warpsfx2 = combobuf[cids[i]].attribytes[0];
21470 index=1;
21471 }
21472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334772 times.
7334772 else if(types[i]==cSWIMWARPC)
21473 {
21474 types[i]=cSWIMWARP;
21475 warpsfx2 = combobuf[cids[i]].attribytes[0];
21476 index=2;
21477 }
21478
1/2
✓ Branch 0 taken 7334772 times.
✗ Branch 1 not taken.
7334772 else if(types[i]==cSWIMWARPD)
21479 {
21480 types[i]=cSWIMWARP;
21481 warpsfx2 = combobuf[cids[i]].attribytes[0];
21482 index=3;
21483 }
21484
21485
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 7334340 times.
7334848 if(types[i]==cDIVEWARP)
21486 {
21487 508 index=0;
21488 508 warpsfx2 = combobuf[cids[i]].attribytes[0];
21489 508 }
21490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334340 times.
7334340 else if(types[i]==cDIVEWARPB)
21491 {
21492 types[i]=cDIVEWARP;
21493 warpsfx2 = combobuf[cids[i]].attribytes[0];
21494 index=1;
21495 }
21496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334340 times.
7334340 else if(types[i]==cDIVEWARPC)
21497 {
21498 types[i]=cDIVEWARP;
21499 warpsfx2 = combobuf[cids[i]].attribytes[0];
21500 index=2;
21501 }
21502
1/2
✓ Branch 0 taken 7334340 times.
✗ Branch 1 not taken.
7334340 else if(types[i]==cDIVEWARPD)
21503 {
21504 types[i]=cDIVEWARP;
21505 warpsfx2 = combobuf[cids[i]].attribytes[0];
21506 index=3;
21507 }
21508
21509
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 7334158 times.
7334848 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
21510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334158 times.
7334158 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
21511
2/2
✓ Branch 0 taken 7334142 times.
✓ Branch 1 taken 16 times.
7334158 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
21512 7334848 }
21513
21514 // Special case for step combos; otherwise, they act oddly in some cases
21515
8/8
✓ Branch 0 taken 1714042 times.
✓ Branch 1 taken 119917 times.
✓ Branch 2 taken 1699448 times.
✓ Branch 3 taken 14594 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 134428 times.
✓ Branch 6 taken 20331 times.
✓ Branch 7 taken 20248 times.
1833959 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
21516 {
21517
7/8
✓ Branch 0 taken 1665451 times.
✓ Branch 1 taken 13666 times.
✓ Branch 2 taken 1665451 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 1665149 times.
✓ Branch 6 taken 130 times.
✓ Branch 7 taken 172 times.
1719779 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21518 1665321 type = types[1];
21519 1679117 }
21520
21521 //Generic Step
21522
7/8
✓ Branch 0 taken 1818832 times.
✓ Branch 1 taken 14961 times.
✓ Branch 2 taken 1818832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✓ Branch 5 taken 1818528 times.
✓ Branch 6 taken 132 times.
✓ Branch 7 taken 172 times.
1833793 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21523 {
21524 int32_t poses[4];
21525 int32_t sensPoses[4];
21526 1818700 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
21527 1818700 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
21528
3/4
✓ Branch 0 taken 1195803 times.
✓ Branch 1 taken 622897 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1195803 times.
1818700 if(diagonalMovement||NO_GRIDLOCK)
21529 622897 getPoses(poses, tx+4, ty+4, tx+11, ty+11);
21530 1195803 else getPoses(poses, tx, ty, tx+15, ty+15);
21531 1818700 getPoses(sensPoses, tx, ty+(bigHitbox?0:8), tx+15, ty+15);
21532 1818700 bool hasStep[4] = {false};
21533
2/2
✓ Branch 0 taken 7274800 times.
✓ Branch 1 taken 1818700 times.
9093500 for(auto p = 0; p < 4; ++p)
21534 {
21535
2/2
✓ Branch 0 taken 7273935 times.
✓ Branch 1 taken 50918410 times.
58192345 for(auto lyr = 0; lyr < 7; ++lyr)
21536 {
21537
2/2
✓ Branch 0 taken 23800462 times.
✓ Branch 1 taken 27117948 times.
50918410 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21538
4/4
✓ Branch 0 taken 23800462 times.
✓ Branch 1 taken 27117948 times.
✓ Branch 2 taken 865 times.
✓ Branch 3 taken 50917545 times.
50918410 if((cmb && (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS)))
21539 50918410 || types[p] == cSTEP)
21540 {
21541 865 hasStep[p] = true;
21542 865 break;
21543 }
21544 50917545 }
21545 7274800 }
21546 1818700 bool canNormalStep = true;
21547
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 1819106 times.
1819205 for(auto p = 0; p < 4; ++p)
21548 {
21549
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 1818853 times.
1819106 if(poses[p] < 0) continue;
21550
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 1818601 times.
1818853 if(!hasStep[p])
21551 {
21552 1818601 canNormalStep = false;
21553 1818601 break;
21554 }
21555 252 }
21556
2/2
✓ Branch 0 taken 7274800 times.
✓ Branch 1 taken 1818700 times.
9093500 for(auto p = 0; p < 4; ++p)
21557 {
21558
2/2
✓ Branch 0 taken 50923600 times.
✓ Branch 1 taken 7274800 times.
58198400 for(auto lyr = 0; lyr < 7; ++lyr)
21559 {
21560
2/2
✓ Branch 0 taken 23803738 times.
✓ Branch 1 taken 27119862 times.
50923600 newcombo const* cmb = poses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[poses[p]]];
21561
2/2
✓ Branch 0 taken 20753712 times.
✓ Branch 1 taken 30169888 times.
50923600 newcombo const* cmb2 = sensPoses[p]<0 ? nullptr : &combobuf[FFCore.tempScreens[lyr]->data[sensPoses[p]]];
21562
6/6
✓ Branch 0 taken 2772 times.
✓ Branch 1 taken 50920828 times.
✓ Branch 2 taken 1162 times.
✓ Branch 3 taken 1610 times.
✓ Branch 4 taken 1148 times.
✓ Branch 5 taken 14 times.
50923600 if(canNormalStep && cmb && (cmb->triggerflags[0] & combotriggerSTEP))
21563 {
21564 14 do_trigger_combo(lyr,poses[p]);
21565
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 9 times.
14 if(poses[p] == sensPoses[p]) continue;
21566 9 }
21567
4/4
✓ Branch 0 taken 20753707 times.
✓ Branch 1 taken 30169888 times.
✓ Branch 2 taken 20753642 times.
✓ Branch 3 taken 65 times.
50923595 if(cmb2 && (cmb2->triggerflags[0] & combotriggerSTEPSENS))
21568 {
21569 65 do_trigger_combo(lyr,sensPoses[p]);
21570 65 }
21571 50923595 }
21572 7274800 }
21573 1818700 word c = tmpscr->numFFC();
21574
2/2
✓ Branch 0 taken 54196815 times.
✓ Branch 1 taken 1818700 times.
56015515 for(word i=0; i<c; i++)
21575 {
21576 54196815 bool found = false;
21577
2/2
✓ Branch 0 taken 108393630 times.
✓ Branch 1 taken 54196815 times.
162590445 for(auto xch = 0; xch < 2; ++xch)
21578 {
21579
2/2
✓ Branch 0 taken 216787260 times.
✓ Branch 1 taken 108393630 times.
325180890 for(auto ych = 0; ych < 2; ++ych)
21580 {
21581
2/2
✓ Branch 0 taken 216709256 times.
✓ Branch 1 taken 78004 times.
216787260 if (ffcIsAt(i, xPoses[xch], yPoses[ych]))
21582 {
21583 78004 found = true;
21584 78004 }
21585 216787260 }
21586 108393630 }
21587
2/2
✓ Branch 0 taken 54165915 times.
✓ Branch 1 taken 30900 times.
54196815 if (found)
21588 {
21589 30900 ffcdata& ffc = tmpscr->ffcs[i];
21590 30900 newcombo const* cmb = &combobuf[ffc.getData()];
21591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30900 times.
30900 if (cmb->triggerflags[0] & (combotriggerSTEP|combotriggerSTEPSENS))
21592 {
21593 do_trigger_combo_ffc(i);
21594 }
21595 30900 }
21596 54196815 }
21597 1818700 }
21598
21599 //
21600 // Now, let's check for Save combos...
21601 //
21602 1833793 x1 = tx+4;
21603 1833793 x2 = tx+11;
21604 1833793 y1 = ty+4;
21605 1833793 y2 = ty+11;
21606
21607 1833793 types[0] = COMBOTYPE(x1,y1);
21608 1833793 cids[0] = MAPCOMBO(x1,y1);
21609
21610
2/2
✓ Branch 0 taken 1812312 times.
✓ Branch 1 taken 21481 times.
1833793 if(MAPFFCOMBO(x1,y1))
21611 {
21612 21481 types[0] = FFCOMBOTYPE(x1,y1);
21613 21481 cids[0] = MAPFFCOMBO(x1,y1);
21614 21481 }
21615
21616 1833793 types[1] = COMBOTYPE(x1,y2);
21617 1833793 cids[1] = MAPCOMBO(x1,y2);
21618
21619
2/2
✓ Branch 0 taken 1817759 times.
✓ Branch 1 taken 16034 times.
1833793 if(MAPFFCOMBO(x1,y2))
21620 {
21621 16034 types[1] = FFCOMBOTYPE(x1,y2);
21622 16034 cids[1] = MAPFFCOMBO(x1,y2);
21623 16034 }
21624
21625 1833793 types[2] = COMBOTYPE(x2,y1);
21626 1833793 cids[2] = MAPCOMBO(x2,y1);
21627
21628
2/2
✓ Branch 0 taken 1812185 times.
✓ Branch 1 taken 21608 times.
1833793 if(MAPFFCOMBO(x2,y1))
21629 {
21630 21608 types[2] = FFCOMBOTYPE(x2,y1);
21631 21608 cids[2] = MAPFFCOMBO(x2,y1);
21632 21608 }
21633
21634 1833793 types[3] = COMBOTYPE(x2,y2);
21635 1833793 cids[3] = MAPCOMBO(x2,y2);
21636
21637
2/2
✓ Branch 0 taken 1817620 times.
✓ Branch 1 taken 16173 times.
1833793 if(MAPFFCOMBO(x2,y2))
21638 {
21639 16173 types[3] = FFCOMBOTYPE(x2,y2);
21640 16173 cids[3] = MAPFFCOMBO(x2,y2);
21641 16173 }
21642
21643
21644
2/2
✓ Branch 0 taken 1833793 times.
✓ Branch 1 taken 7335172 times.
9168965 for(int32_t i=0; i<4; i++)
21645 {
21646
2/2
✓ Branch 0 taken 7334848 times.
✓ Branch 1 taken 324 times.
7335172 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21647 {
21648
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 324 times.
✗ Branch 3 not taken.
324 if(types[i] == cSAVE || types[i] == cSAVE2)
21649 {
21650 types[i] = cNONE;
21651 setsave = false;
21652 break;
21653 }
21654 324 }
21655
2/2
✓ Branch 0 taken 7333886 times.
✓ Branch 1 taken 1286 times.
7335172 if(types[i]==cSAVE) setsave=true;
21656
21657
1/2
✓ Branch 0 taken 7335172 times.
✗ Branch 1 not taken.
7335172 if(types[i]==cSAVE2) setsave=true;
21658 7335172 }
21659
21660
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 1833362 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
1833793 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
21661 {
21662 229 last_savepoint_id = cids[0];
21663 229 type = types[0];
21664 229 }
21665 //
21666 // Now, let's check for Drowning combos...
21667 //
21668
3/4
✓ Branch 0 taken 1075103 times.
✓ Branch 1 taken 758690 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1075103 times.
1833793 if(get_bit(quest_rules,qr_DROWN) || CanSideSwim())
21669 {
21670 758690 y1 = ty+9;
21671 758690 y2 = ty+15;
21672
2/2
✓ Branch 0 taken 229175 times.
✓ Branch 1 taken 529515 times.
758690 if (get_bit(quest_rules, qr_SMARTER_WATER))
21673 {
21674
4/4
✓ Branch 0 taken 1888 times.
✓ Branch 1 taken 227287 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1598 times.
230776 if (iswaterex(0, currmap, currscr, -1, x1, y1, true, false) &&
21675
2/2
✓ Branch 0 taken 1724 times.
✓ Branch 1 taken 164 times.
1888 iswaterex(0, currmap, currscr, -1, x1, y2, true, false) &&
21676
2/2
✓ Branch 0 taken 1601 times.
✓ Branch 1 taken 123 times.
1724 iswaterex(0, currmap, currscr, -1, x2, y1, true, false) &&
21677 1601 iswaterex(0, currmap, currscr, -1, x2, y2, true, false)) water = iswaterex(0, currmap, currscr, -1, (x2+x1)/2,(y2+y1)/2, true, false);
21678 229175 }
21679 else
21680 {
21681 529515 types[0] = COMBOTYPE(x1,y1);
21682
21683
2/2
✓ Branch 0 taken 11301 times.
✓ Branch 1 taken 518214 times.
529515 if(MAPFFCOMBO(x1,y1))
21684 11301 types[0] = FFCOMBOTYPE(x1,y1);
21685
21686 529515 types[1] = COMBOTYPE(x1,y2);
21687
21688
2/2
✓ Branch 0 taken 10868 times.
✓ Branch 1 taken 518647 times.
529515 if(MAPFFCOMBO(x1,y2))
21689 10868 types[1] = FFCOMBOTYPE(x1,y2);
21690
21691 529515 types[2] = COMBOTYPE(x2,y1);
21692
21693
2/2
✓ Branch 0 taken 12015 times.
✓ Branch 1 taken 517500 times.
529515 if(MAPFFCOMBO(x2,y1))
21694 12015 types[2] = FFCOMBOTYPE(x2,y1);
21695
21696 529515 types[3] = COMBOTYPE(x2,y2);
21697
21698
2/2
✓ Branch 0 taken 11358 times.
✓ Branch 1 taken 518157 times.
529515 if(MAPFFCOMBO(x2,y2))
21699 11358 types[3] = FFCOMBOTYPE(x2,y2);
21700
21701 529515 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
21702
2/2
✓ Branch 0 taken 11562 times.
✓ Branch 1 taken 517953 times.
529515 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
21703 11562 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
21704
21705
5/6
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 527623 times.
✓ Branch 2 taken 1888 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1852 times.
✗ Branch 5 not taken.
531367 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
21706
3/4
✓ Branch 0 taken 1852 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 1852 times.
✗ Branch 3 not taken.
1888 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
21707 1852 water = typec;
21708 }
21709 758690 }
21710
21711
21712 // Pits have a bigger 'hitbox' than stairs...
21713 1833793 x1 = tx+7;
21714 1833793 x2 = tx+8;
21715 1833793 y1 = ty+7+(bigHitbox?0:4);
21716 1833793 y2 = ty+8+(bigHitbox?0:4);
21717
21718 1833793 types[0] = COMBOTYPE(x1,y1);
21719 1833793 cids[0] = MAPCOMBO(x1,y1);
21720
21721
2/2
✓ Branch 0 taken 1817405 times.
✓ Branch 1 taken 16388 times.
1833793 if(MAPFFCOMBO(x1,y1))
21722 {
21723 16388 types[0] = FFCOMBOTYPE(x1,y1);
21724 16388 cids[0] = MAPFFCOMBO(x1,y1);
21725 16388 }
21726
21727 1833793 types[1] = COMBOTYPE(x1,y2);
21728 1833793 cids[1] = MAPCOMBO(x1,y2);
21729
21730
2/2
✓ Branch 0 taken 1817472 times.
✓ Branch 1 taken 16321 times.
1833793 if(MAPFFCOMBO(x1,y2))
21731 {
21732 16321 types[1] = FFCOMBOTYPE(x1,y2);
21733 16321 cids[1] = MAPFFCOMBO(x1,y2);
21734 16321 }
21735 1833793 types[2] = COMBOTYPE(x2,y1);
21736 1833793 cids[2] = MAPCOMBO(x2,y1);
21737
21738
2/2
✓ Branch 0 taken 1817755 times.
✓ Branch 1 taken 16038 times.
1833793 if(MAPFFCOMBO(x2,y1))
21739 {
21740 16038 types[2] = FFCOMBOTYPE(x2,y1);
21741 16038 cids[2] = MAPFFCOMBO(x2,y1);
21742 16038 }
21743
21744 1833793 types[3] = COMBOTYPE(x2,y2);
21745 1833793 cids[3] = MAPCOMBO(x2,y2);
21746
21747
2/2
✓ Branch 0 taken 1817817 times.
✓ Branch 1 taken 15976 times.
1833793 if(MAPFFCOMBO(x2,y2))
21748 {
21749 15976 types[3] = FFCOMBOTYPE(x2,y2);
21750 15976 cids[3] = MAPFFCOMBO(x2,y2);
21751 15976 }
21752
21753
2/2
✓ Branch 0 taken 7335172 times.
✓ Branch 1 taken 1833793 times.
9168965 for(int32_t i=0; i<4; i++)
21754 {
21755
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 7334908 times.
7335172 if(combobuf[cids[i]].triggerflags[0] & combotriggerONLYGENTRIG)
21756 {
21757 264 types[i] = cNONE;
21758 264 continue;
21759 }
21760
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 7334732 times.
7334908 if(types[i]==cPIT)
21761 {
21762 176 index=0;
21763 176 warpsfx2 = combobuf[cids[i]].attribytes[0];
21764 176 }
21765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334732 times.
7334732 else if(types[i]==cPITB)
21766 {
21767 types[i]=cPIT;
21768 index=1;
21769 warpsfx2 = combobuf[cids[i]].attribytes[0];
21770 }
21771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7334732 times.
7334732 else if(types[i]==cPITC)
21772 {
21773 types[i]=cPIT;
21774 index=2;
21775 warpsfx2 = combobuf[cids[i]].attribytes[0];
21776 }
21777
1/2
✓ Branch 0 taken 7334732 times.
✗ Branch 1 not taken.
7334732 else if(types[i]==cPITD)
21778 {
21779 types[i]=cPIT;
21780 index=3;
21781 warpsfx2 = combobuf[cids[i]].attribytes[0];
21782 }
21783 7334908 }
21784
21785
6/8
✓ Branch 0 taken 1833752 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 1833752 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1833746 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1833746 times.
1833793 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
21786
3/8
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
94 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_bit(quest_rules,qr_MSGFREEZE)))
21787 47 type=cPIT;
21788
21789 //
21790 // Time to act on our results for type, flag, flag2 and flag3...
21791 //
21792
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 1833564 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
1833793 if(type==cSAVE&&currscr<128)
21793 229 *ls=1;
21794
21795
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1833793 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1833793 if(type==cSAVE2&&currscr<128)
21796 *ls=2;
21797
21798
7/8
✓ Branch 0 taken 1826301 times.
✓ Branch 1 taken 7492 times.
✓ Branch 2 taken 1816432 times.
✓ Branch 3 taken 9869 times.
✓ Branch 4 taken 1815902 times.
✓ Branch 5 taken 530 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1815902 times.
1833793 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
21799 {
21800 17891 fairycircle(REFILL_LIFE);
21801
21802
2/2
✓ Branch 0 taken 14944 times.
✓ Branch 1 taken 2947 times.
17891 if(fairyclk!=0) return;
21803 2947 }
21804
21805
4/8
✓ Branch 0 taken 1818849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1818849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1818849 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1818849 times.
1818849 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
21806 {
21807 fairycircle(REFILL_MAGIC);
21808
21809 if(fairyclk!=0) return;
21810 }
21811
21812
4/8
✓ Branch 0 taken 1818849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1818849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1818849 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1818849 times.
1818849 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
21813 {
21814 fairycircle(REFILL_ALL);
21815
21816 if(fairyclk!=0) return;
21817 }
21818
21819 // Just in case Hero was moved off of the fairy flag
21820
1/2
✓ Branch 0 taken 1818849 times.
✗ Branch 1 not taken.
1818849 if(refilling==REFILL_FAIRYDONE)
21821 {
21822 fairycircle(REFILL_NONE);
21823
21824 if(fairyclk!=0) return;
21825 }
21826
21827
5/8
✓ Branch 0 taken 1818843 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1818843 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1818843 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1818843 times.
1818849 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
21828 {
21829 6 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
21830 6 win_game();
21831 6 return;
21832 }
21833
21834
4/4
✓ Branch 0 taken 1815643 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 1815643 times.
✓ Branch 3 taken 3200 times.
1818843 if((z>0 || fakez>0) && !(tmpscr->flags2&fAIRCOMBOS))
21835 3200 return;
21836
21837
3/4
✓ Branch 0 taken 1815643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1815639 times.
1815643 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
21838 {
21839
21840
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
4 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepsecret || get_bit(quest_rules,qr_TRIGGERSREPEAT))
21841 {
21842 4 stepsecret = (((ty+8)&0xF0)+((tx+8)>>4));
21843 4 sfx(combobuf[tmpscr->data[stepsecret]].attribytes[0],pan((int32_t)x));
21844 //zprint("Step Secrets Sound: %d\n", combobuf[tmpscr->data[stepsecret]].attribytes[0]);
21845
21846
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(type==cTRIGFLAG && canPermSecret())
21847 {
21848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(!(tmpscr->flags5&fTEMPSECRETS)) setmapflag(mSECRET);
21849
21850 4 hidden_entrance(0,true,false);
21851 4 }
21852 else
21853 {
21854 bool only16_31 = get_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
21855 hidden_entrance(0,true,only16_31);
21856 }
21857 4 }
21858 4 }
21859
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 1815297 times.
1815639 else if(!didstrig)
21860 {
21861 1815297 stepsecret = -1;
21862 1815297 }
21863
21864 //Better? Dock collision
21865
21866 // Drown if:
21867 // * Water (obviously walkable),
21868 // * Quest Rule allows it,
21869 // * Not on stepladder,
21870 // * Not jumping,
21871 // * Not hovering,
21872 // * Not rafting,
21873 // * Not swallowed,
21874 // * Not a dried lake.
21875
21876 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
21877
21878
13/22
✓ Branch 0 taken 3394 times.
✓ Branch 1 taken 1812249 times.
✓ Branch 2 taken 3394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3394 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3394 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3394 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 3387 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3011 times.
✓ Branch 15 taken 376 times.
✓ Branch 16 taken 3011 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 3011 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1815643 if(water > 0 && ((get_bit(quest_rules,qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim()) && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE)
21879 {
21880
4/8
✓ Branch 0 taken 3000 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 3000 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3000 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3011 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
21881 {
21882
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(!(ladderx+laddery)) drownCombo = water;
21883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (combobuf[water].usrflags&cflag1) Drown(1);
21884 11 else Drown();
21885
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
11 if(byte drown_sfx = combobuf[water].attribytes[4])
21886 8 sfx(drown_sfx, pan(int32_t(x)));
21887 11 }
21888
2/2
✓ Branch 0 taken 2891 times.
✓ Branch 1 taken 109 times.
3000 else if (!isSwimming())
21889 {
21890 109 SetSwim();
21891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (!IsSideSwim()) attackclk = charging = spins = 0;
21892 109 landswim=0;
21893 109 return;
21894 }
21895 2902 }
21896
21897
21898
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 1815371 times.
1815534 if(type==cSTEP)
21899 {
21900 //zprint2("Hero.HasHeavyBoots(): is: %s\n", ( (Hero.HasHeavyBoots()) ? "true" : "false" ));
21901
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 66 times.
163 if((((ty+8)&0xF0)+((tx+8)>>4))!=stepnext)
21902 {
21903 66 stepnext=((ty+8)&0xF0)+((tx+8)>>4);
21904
21905 if
21906 (
21907
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 4 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
21908
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 (!combobuf[tmpscr->data[stepnext]].attribytes[1] || (combobuf[tmpscr->data[stepnext]].attribytes[1] && game->item[combobuf[tmpscr->data[stepnext]].attribytes[1]]) )
21909 && /*HEAVY*/
21910
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21911 )
21912
21913 {
21914 62 sfx(combobuf[tmpscr->data[stepnext]].attribytes[0],pan((int32_t)x));
21915 62 tmpscr->data[stepnext]++;
21916
21917 62 }
21918
21919 if
21920 (
21921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
21922 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21923 && /*HEAVY*/
21924 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21925 )
21926 {
21927 int32_t stepc = tmpscr->data[stepnext];
21928 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21929 for(int32_t k=0; k<176; k++)
21930 {
21931 if(tmpscr->data[k]==stepc)
21932 {
21933 tmpscr->data[k]++;
21934 }
21935 }
21936 }
21937
21938 if
21939 (
21940
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 63 times.
66 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
21941
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] && game->item[combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1]]) )
21942 && /*HEAVY*/
21943
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 ( ( !(combobuf[tmpscr->data[stepnext]].usrflags&cflag1) ) || ((combobuf[tmpscr->data[stepnext]].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
21944 )
21945 {
21946 3 sfx(combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[0],pan((int32_t)x));
21947
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
531 for(int32_t k=0; k<176; k++)
21948 {
21949 if(
21950
3/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 507 times.
1050 (combobuf[tmpscr->data[k]].type==cSTEP)||
21951
1/2
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
528 (combobuf[tmpscr->data[k]].type==cSTEPSAME)||
21952
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 6 times.
528 (combobuf[tmpscr->data[k]].type==cSTEPALL)||
21953 522 (combobuf[tmpscr->data[k]].type==cSTEPCOPY)
21954 )
21955 {
21956 21 tmpscr->data[k]++;
21957 21 }
21958 528 }
21959 3 }
21960 66 }
21961 163 }
21962
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1815371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1815371 else if(type==cSTEPSFX && action == walking)
21963 {
21964 trigger_stepfx(0, COMBOPOS(tx+8,ty+8), true);
21965 }
21966 1815371 else stepnext = -1;
21967
21968 1815534 detail_int[0]=tx;
21969 1815534 detail_int[1]=ty;
21970
21971
21972
8/8
✓ Branch 0 taken 1815392 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 245 times.
✓ Branch 3 taken 1815289 times.
✓ Branch 4 taken 1814543 times.
✓ Branch 5 taken 746 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 8 times.
1815547 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
21973
5/6
✓ Branch 0 taken 1814496 times.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 1814485 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 1814485 times.
✗ Branch 5 not taken.
1814543 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
21974
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1814472 times.
1814485 !(type==cDIVEWARP && isDiving()))
21975 1814480 {
21976 RaftingStuff:
21977
2/2
✓ Branch 0 taken 1813921 times.
✓ Branch 1 taken 559 times.
1814480 if (get_bit(quest_rules, qr_BETTER_RAFT_2))
21978 {
21979 559 bool doraft = true;
21980
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
21981 {
21982
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
21983 {
21984 3 doraft = false;
21985 3 }
21986 3 }
21987 //if (mfRAFT)
21988 int32_t rafttypes[2];
21989 559 int32_t raftx1 = tx+6;
21990 559 int32_t raftx2 = tx+9;
21991 559 int32_t rafty = ty+11;
21992 int32_t raftflags[3];
21993 559 rafttypes[0]=rafttypes[1]=-1;
21994 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
21995 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
21996 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
21997
21998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
21999 559 raftflags[0] = rafttypes[0];
22000
22001
22002 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
22003 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
22004
22005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
22006 559 raftflags[1] = rafttypes[0];
22007
22008 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
22009 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
22010
22011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
22012 559 raftflags[2] = rafttypes[0];
22013
22014
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
22015 {
22016
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
22017 {
22018 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
22019 {
22020 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
22021 {
22022 reset_swordcharge();
22023 action=rafting; FFCore.setHeroAction(rafting);
22024 raftclk=0;
22025 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22026 else sfx(tmpscr->secretsfx);
22027 }
22028 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22029 {
22030 for (int32_t i = 0; i < 4; ++i)
22031 {
22032 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
22033 {
22034 reset_swordcharge();
22035 action=rafting; FFCore.setHeroAction(rafting);
22036 raftclk=0;
22037 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22038 else sfx(tmpscr->secretsfx);
22039 dir = i;
22040 break;
22041 }
22042 }
22043 }
22044 }
22045 }
22046 1677 }
22047 559 }
22048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1814480 times.
1814480 if (RaftPass) return;
22049
3/3
✓ Branch 0 taken 9244 times.
✓ Branch 1 taken 1804830 times.
✓ Branch 2 taken 406 times.
1814480 switch(flag)
22050 {
22051 case mfDIVE_ITEM:
22052
6/8
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 397 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
406 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
22053 {
22054 12 additem(x, y, tmpscr->catchall,
22055 6 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22056 6 sfx(tmpscr->secretsfx);
22057 6 }
22058
22059 406 return;
22060
22061 case mfRAFT:
22062 case mfRAFT_BRANCH:
22063
22064 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
22065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9244 times.
9244 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
22066 {
22067 9244 bool doraft = true;
22068
5/6
✓ Branch 0 taken 9244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 934 times.
✓ Branch 3 taken 8310 times.
✓ Branch 4 taken 120 times.
✓ Branch 5 taken 814 times.
9244 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
22069 {
22070
5/6
✓ Branch 0 taken 814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 391 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 373 times.
814 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
22071 {
22072 373 doraft = false;
22073 373 }
22074 814 }
22075
13/16
✓ Branch 0 taken 9040 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 1788 times.
✓ Branch 3 taken 7252 times.
✓ Branch 4 taken 1778 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 1776 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 1776 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1776 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1776 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1231 times.
✓ Branch 15 taken 545 times.
9244 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
22076 {
22077
3/4
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 386 times.
545 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
22078 {
22079 159 reset_swordcharge();
22080 159 action=rafting; FFCore.setHeroAction(rafting);
22081 159 raftclk=0;
22082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22083 159 else sfx(tmpscr->secretsfx);
22084 159 }
22085
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 386 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
386 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22086 {
22087 for (int32_t i = 0; i < 4; ++i)
22088 {
22089 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
22090 {
22091 reset_swordcharge();
22092 action=rafting; FFCore.setHeroAction(rafting);
22093 raftclk=0;
22094 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22095 else sfx(tmpscr->secretsfx);
22096 dir = i;
22097 break;
22098 }
22099 }
22100 }
22101 545 }
22102 9244 }
22103
22104 9244 return;
22105
22106 default:
22107 1804830 break;
22108 //return;
22109 }
22110
22111
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1804830 times.
✗ Branch 2 not taken.
1804830 switch(flag2)
22112 {
22113 case mfDIVE_ITEM:
22114 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
22115 {
22116 additem(x, y, tmpscr->catchall,
22117 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22118 sfx(tmpscr->secretsfx);
22119 }
22120
22121 return;
22122
22123 case mfRAFT:
22124 case mfRAFT_BRANCH:
22125
22126 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
22127 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
22128 {
22129 bool doraft = true;
22130 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
22131 {
22132 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
22133 {
22134 doraft = false;
22135 }
22136 }
22137 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
22138 {
22139 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
22140 {
22141 reset_swordcharge();
22142 action=rafting; FFCore.setHeroAction(rafting);
22143 raftclk=0;
22144 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22145 else sfx(tmpscr->secretsfx);
22146 }
22147 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22148 {
22149 for (int32_t i = 0; i < 4; ++i)
22150 {
22151 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
22152 {
22153 reset_swordcharge();
22154 action=rafting; FFCore.setHeroAction(rafting);
22155 raftclk=0;
22156 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22157 else sfx(tmpscr->secretsfx);
22158 dir = i;
22159 break;
22160 }
22161 }
22162 }
22163 }
22164 }
22165
22166 return;
22167
22168 default:
22169 1804830 break;
22170 //return;
22171 }
22172
22173
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1804830 times.
✗ Branch 2 not taken.
1804830 switch(flag3)
22174 {
22175 case mfDIVE_ITEM:
22176 if(isDiving() && (!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN)))
22177 {
22178 additem(x, y, tmpscr->catchall,
22179 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22180 sfx(tmpscr->secretsfx);
22181 }
22182
22183 return;
22184
22185 case mfRAFT:
22186 case mfRAFT_BRANCH:
22187
22188 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
22189 if (!get_bit(quest_rules, qr_BETTER_RAFT_2))
22190 {
22191 bool doraft = true;
22192 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
22193 {
22194 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
22195 {
22196 doraft = false;
22197 }
22198 }
22199 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
22200 {
22201 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
22202 {
22203 reset_swordcharge();
22204 action=rafting; FFCore.setHeroAction(rafting);
22205 raftclk=0;
22206 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22207 else sfx(tmpscr->secretsfx);
22208 }
22209 else if (get_bit(quest_rules, qr_BETTER_RAFT) && doraft)
22210 {
22211 for (int32_t i = 0; i < 4; ++i)
22212 {
22213 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
22214 {
22215 reset_swordcharge();
22216 action=rafting; FFCore.setHeroAction(rafting);
22217 raftclk=0;
22218 if (get_bit(quest_rules, qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x.getInt()));
22219 else sfx(tmpscr->secretsfx);
22220 dir = i;
22221 break;
22222 }
22223 }
22224 }
22225 }
22226 }
22227
22228 return;
22229
22230 default:
22231 1804830 return;
22232 }
22233 }
22234
22235
22236 1054 int32_t t=(currscr<128)?0:1;
22237
22238
3/4
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 1054 times.
✗ Branch 3 not taken.
1054 if((type==cCAVE || type==cCAVE2) && (tmpscr[t].tilewarptype[index]==wtNOWARP)) return;
22239
22240 //don't do this for canceled warps -DD
22241 //I have no idea why we do this skip, but I'll dutifully propagate it to all cases below...
22242 /*if(tmpscr[t].tilewarptype[index] != wtNOWARP)
22243 {
22244 draw_screen(tmpscr);
22245 advanceframe(true);
22246 }*/
22247
22248 1054 bool skippedaframe=false;
22249
22250
6/6
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 809 times.
✓ Branch 3 taken 103 times.
✓ Branch 4 taken 746 times.
✓ Branch 5 taken 63 times.
1054 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
22251 {
22252 // Stop music only if:
22253 // * entering a Guy Cave
22254 // * warping to a DMap whose music is different.
22255
22256 991 int32_t tdm = tmpscr[t].tilewarpdmap[index];
22257
22258
2/2
✓ Branch 0 taken 647 times.
✓ Branch 1 taken 344 times.
991 if(tmpscr[t].tilewarptype[index]<=wtPASS)
22259 {
22260
3/4
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 313 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 334 times.
647 if((DMaps[currdmap].flags&dmfCAVES) && tmpscr[t].tilewarptype[index] == wtCAVE)
22261 334 music_stop();
22262 647 }
22263 else
22264 {
22265
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 334 times.
344 if(zcmusic!=NULL)
22266 {
22267
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
20 if(strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
22268
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 (zcmusic->type==ZCMF_GME && zcmusic->track!=DMaps[tdm].tmusictrack))
22269 10 music_stop();
22270 10 }
22271
3/4
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
334 else if(DMaps[tmpscr->tilewarpdmap[index]].midi != (currmidi-ZC_MIDI_COUNT+4) &&
22272 292 TheMaps[(DMaps[tdm].map*MAPSCRS + (tmpscr[t].tilewarpscr[index] + DMaps[tdm].xoff))].screen_midi != (currmidi-ZC_MIDI_COUNT+4))
22273 292 music_stop();
22274 }
22275
22276 991 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
22277
5/6
✓ Branch 0 taken 647 times.
✓ Branch 1 taken 344 times.
✓ Branch 2 taken 334 times.
✓ Branch 3 taken 313 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 334 times.
991 bool opening = (tmpscr[t].tilewarptype[index]<=wtPASS && !(DMaps[currdmap].flags&dmfCAVES && tmpscr[t].tilewarptype[index]==wtCAVE)
22278 678 ? false : COOLSCROLL);
22279
22280 991 FFCore.warpScriptCheck();
22281 991 draw_screen(tmpscr);
22282 991 advanceframe(true);
22283
22284 991 skippedaframe=true;
22285
22286
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 888 times.
991 if(type==cCAVE2) walkup2(opening);
22287
2/2
✓ Branch 0 taken 746 times.
✓ Branch 1 taken 142 times.
888 else if(type==cCAVE) walkdown(opening);
22288 991 }
22289
22290
2/2
✓ Branch 0 taken 1007 times.
✓ Branch 1 taken 47 times.
1054 if(type==cPIT)
22291 {
22292 47 didpit=true;
22293 47 pitx=x;
22294 47 pity=y;
22295 47 warp_sound = warpsfx2;
22296 47 }
22297
22298
5/6
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 474 times.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
1110 if(DMaps[currdmap].flags&dmf3STAIR && (currscr==129 || !(DMaps[currdmap].flags&dmfGUYCAVES))
22299
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
580 && tmpscr[specialcave > 0 && DMaps[currdmap].flags&dmfGUYCAVES ? 1:0].room==rWARP && type==cSTAIR)
22300 {
22301
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(!skippedaframe)
22302 {
22303 FFCore.warpScriptCheck();
22304 draw_screen(tmpscr);
22305 advanceframe(true);
22306 }
22307
22308 // "take any road you want"
22309
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 11 times.
56 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
22310 56 int32_t code = WARPCODE(currdmap,homescr,dw);
22311
22312
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(code>-1)
22313 {
22314 56 bool changedlevel = false;
22315 56 bool changeddmap = false;
22316
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(currdmap != code>>8)
22317 {
22318 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22319 15 changeddmap = true;
22320 15 }
22321
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(dlevel != DMaps[code>>8].level)
22322 {
22323 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22324 changedlevel = true;
22325 }
22326 56 currdmap = code>>8;
22327 56 dlevel = DMaps[currdmap].level;
22328
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 15 times.
56 if(changeddmap)
22329 {
22330 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22331 15 }
22332
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(changedlevel)
22333 {
22334 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22335 }
22336
22337 56 currmap = DMaps[currdmap].map;
22338 56 homescr = (code&0xFF) + DMaps[currdmap].xoff;
22339 56 init_dmap();
22340
22341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(canPermSecret())
22342 56 setmapflag(mSECRET);
22343 56 }
22344
22345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 if(specialcave==STAIRCAVE) exitcave();
22346
22347 56 return;
22348 }
22349
22350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 998 times.
998 if(type==cRESET)
22351 {
22352 if(!skippedaframe)
22353 {
22354 FFCore.warpScriptCheck();
22355 draw_screen(tmpscr);
22356 advanceframe(true);
22357 }
22358
22359 if(!(tmpscr->noreset&mSECRET)) unsetmapflag(mSECRET);
22360
22361 if(!(tmpscr->noreset&mITEM)) unsetmapflag(mITEM);
22362
22363 if(!(tmpscr->noreset&mSPECIALITEM)) unsetmapflag(mSPECIALITEM);
22364
22365 if(!(tmpscr->noreset&mNEVERRET)) unsetmapflag(mNEVERRET);
22366
22367 if(!(tmpscr->noreset&mCHEST)) unsetmapflag(mCHEST);
22368
22369 if(!(tmpscr->noreset&mLOCKEDCHEST)) unsetmapflag(mLOCKEDCHEST);
22370
22371 if(!(tmpscr->noreset&mBOSSCHEST)) unsetmapflag(mBOSSCHEST);
22372
22373 if(!(tmpscr->noreset&mLOCKBLOCK)) unsetmapflag(mLOCKBLOCK);
22374
22375 if(!(tmpscr->noreset&mBOSSLOCKBLOCK)) unsetmapflag(mBOSSLOCKBLOCK);
22376
22377 if(isdungeon())
22378 {
22379 if(!(tmpscr->noreset&mDOOR_LEFT)) unsetmapflag(mDOOR_LEFT);
22380
22381 if(!(tmpscr->noreset&mDOOR_RIGHT)) unsetmapflag(mDOOR_RIGHT);
22382
22383 if(!(tmpscr->noreset&mDOOR_DOWN)) unsetmapflag(mDOOR_DOWN);
22384
22385 if(!(tmpscr->noreset&mDOOR_UP)) unsetmapflag(mDOOR_UP);
22386 }
22387
22388 didpit=true;
22389 pitx=x;
22390 pity=y;
22391 sdir=dir;
22392 dowarp(4,0, warpsfx2);
22393 }
22394 else
22395 {
22396
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 935 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
998 if(!skippedaframe && (tmpscr[t].tilewarptype[index]!=wtNOWARP))
22397 {
22398 63 FFCore.warpScriptCheck();
22399 63 draw_screen(tmpscr);
22400 63 advanceframe(true);
22401 63 }
22402
22403 998 sdir = dir;
22404 998 dowarp(0,index, warpsfx2);
22405 }
22406 5143939 }
22407
22408 39 int32_t selectWlevel(int32_t d)
22409 {
22410
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 if(TriforceCount()==0)
22411 return 0;
22412
22413 39 word l = game->get_wlevel();
22414
22415 39 do
22416 {
22417
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
22418 break;
22419
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 25 times.
72 else if(d<0)
22420
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5 times.
25 l = (l==0) ? 7 : l-1;
22421 else
22422
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 40 times.
47 l = (l==7) ? 0 : l+1;
22423
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 39 times.
72 }
22424 72 while(!(game->lvlitems[l+1] & liTRIFORCE));
22425
22426 39 game->set_wlevel(l);
22427 39 return l;
22428 39 }
22429
22430 // Would someone tell the Dodongos to shut their yaps?!
22431 8859 void kill_enemy_sfx()
22432 {
22433
2/2
✓ Branch 0 taken 8859 times.
✓ Branch 1 taken 14760 times.
23619 for(int32_t i=0; i<guys.Count(); i++)
22434 {
22435
2/2
✓ Branch 0 taken 7354 times.
✓ Branch 1 taken 7406 times.
14760 if(((enemy*)guys.spr(i))->bgsfx)
22436 7406 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
22437 14760 }
22438
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 8821 times.
8859 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
22439
2/2
✓ Branch 0 taken 8853 times.
✓ Branch 1 taken 6 times.
8859 if(tmpscr->room==rGANON)
22440 6 stop_sfx(WAV_ROAR);
22441 8859 }
22442
22443 675 bool HeroClass::HasHeavyBoots()
22444 {
22445
2/2
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 172800 times.
173475 for ( int32_t q = 0; q < MAXITEMS; ++q )
22446 {
22447
5/6
✓ Branch 0 taken 1999 times.
✓ Branch 1 taken 170801 times.
✓ Branch 2 taken 649 times.
✓ Branch 3 taken 1350 times.
✓ Branch 4 taken 649 times.
✗ Branch 5 not taken.
172800 if ( game->item[q] && ( itemsbuf[q].family == itype_boots ) && /*iron*/ (itemsbuf[q].flags&ITEM_FLAG2) ) return true;
22448 172800 }
22449 675 return false;
22450 675 }
22451
22452 const char *roomtype_string[rMAX] =
22453 {
22454 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
22455 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Triforce Check",
22456 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
22457 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash", "More Arrows","Take One Item"
22458 };
22459
22460 1754 bool HeroClass::dowarp(int32_t type, int32_t index, int32_t warpsfx)
22461 {
22462 1754 byte reposition_sword_postwarp = 0;
22463
1/2
✓ Branch 0 taken 1754 times.
✗ Branch 1 not taken.
1754 if(index<0)
22464 {
22465 return false;
22466 }
22467 1754 is_warping = true;
22468
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 1754 times.
1926 for ( int32_t q = 0; q < Lwpns.Count(); ++q )
22469 {
22470 172 weapon *swd=NULL;
22471 172 swd = (weapon*)Lwpns.spr(q);
22472
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 8 times.
172 if(swd->id == (attack==wSword ? wSword : wWand))
22473 {
22474 8 Lwpns.del(q);
22475 8 }
22476 172 }
22477
22478 1754 attackclk = charging = spins = tapping = 0;
22479 1754 attack = none;
22480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1754 times.
1754 if ( warp_sound > 0 ) warpsfx = warp_sound;
22481 1754 warp_sound = 0;
22482 1754 word wdmap=0;
22483 1754 byte wscr=0,wtype=0,t=0;
22484 1754 bool overlay=false;
22485 1754 t=(currscr<128)?0:1;
22486 1754 int32_t wrindex = 0;
22487 1754 bool wasSideview = isSideViewGravity(t); // (tmpscr[t].flags7 & fSIDEVIEW)!=0 && !ignoreSideview;
22488
22489 // Drawing commands probably shouldn't carry over...
22490
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1708 times.
1754 if ( !get_bit(quest_rules,qr_SCRIPTDRAWSINWARPS) )
22491 1708 script_drawing_commands.Clear();
22492
22493
4/6
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1001 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 38 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1754 switch(type)
22494 {
22495 case 0: // tile warp
22496 1001 wtype = tmpscr[t].tilewarptype[index];
22497 1001 wdmap = tmpscr[t].tilewarpdmap[index];
22498 1001 wscr = tmpscr[t].tilewarpscr[index];
22499 1001 overlay = get_bit(&tmpscr[t].tilewarpoverlayflags,index)?1:0;
22500 1001 wrindex=(tmpscr->warpreturnc>>(index*2))&3;
22501 1001 break;
22502
22503 case 1: // side warp
22504 669 wtype = tmpscr[t].sidewarptype[index];
22505 669 wdmap = tmpscr[t].sidewarpdmap[index];
22506 669 wscr = tmpscr[t].sidewarpscr[index];
22507 669 overlay = get_bit(&tmpscr[t].sidewarpoverlayflags,index)?1:0;
22508 669 wrindex=(tmpscr->warpreturnc>>(8+(index*2)))&3;
22509 //tmpscr->doscript = 0; //kill the currebt screen's script so that it does not continue to run during the scroll.
22510 //there is no doscript for screen scripts. They run like ffcs.
22511
22512 669 break;
22513
22514 case 2: // whistle warp
22515 {
22516 38 wtype = wtWHISTLE;
22517
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
22518 38 int32_t level=0;
22519
22520
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(blowcnt==0)
22521 level = selectWlevel(0);
22522 else
22523 {
22524
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
77 for(int32_t i=0; i<abs(blowcnt); i++)
22525 39 level = selectWlevel(blowcnt);
22526 }
22527
22528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
22529 {
22530 level %= QMisc.warp[wind].size;
22531 game->set_wlevel(level);
22532 }
22533
22534 38 wdmap = QMisc.warp[wind].dmap[level];
22535 38 wscr = QMisc.warp[wind].scr[level];
22536 }
22537 38 break;
22538
22539 case 3:
22540 wtype = wtIWARP;
22541 wdmap = cheat_goto_dmap;
22542 wscr = cheat_goto_screen;
22543 break;
22544
22545 case 4:
22546 wtype = wtIWARP;
22547 wdmap = currdmap;
22548 wscr = homescr-DMaps[currdmap].xoff;
22549 break;
22550 }
22551
22552 1754 bool intradmap = (wdmap == currdmap);
22553 1754 int32_t olddmap = currdmap;
22554 1754 rehydratelake(type!=wtSCROLL);
22555
22556
7/8
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 388 times.
✓ Branch 3 taken 203 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 242 times.
✓ Branch 6 taken 38 times.
✓ Branch 7 taken 37 times.
1754 switch(wtype)
22557 {
22558 case wtCAVE:
22559 {
22560 // cave/item room
22561 388 ALLOFF();
22562 388 homescr=currscr;
22563 388 currscr=0x80;
22564
22565
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 110 times.
388 if(DMaps[currdmap].flags&dmfCAVES) // cave
22566 {
22567 278 music_stop();
22568 278 kill_sfx();
22569
22570
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 217 times.
278 if(tmpscr->room==rWARP)
22571 {
22572 61 currscr=0x81;
22573 61 specialcave = STAIRCAVE;
22574 61 }
22575 217 else specialcave = GUYCAVE;
22576
22577 //lighting(2,dir);
22578 278 lighting(false, true);
22579 278 loadlvlpal(10);
22580
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 38 times.
518 bool b2 = COOLSCROLL&&
22581
3/4
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 184 times.
✗ Branch 3 not taken.
240 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
22582
2/4
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 184 times.
✗ Branch 3 not taken.
184 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
22583
2/4
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 184 times.
✗ Branch 3 not taken.
184 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
22584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 184 times.
184 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
22585 278 blackscr(30,b2?false:true);
22586 278 loadscr(0,wdmap,currscr,up,false);
22587 278 loadscr(1,wdmap,homescr,up,false);
22588 //preloaded freeform combos
22589 278 ffscript_engine(true);
22590 278 putscr(scrollbuf,0,0,tmpscr);
22591 278 putscrdoors(scrollbuf,0,0,tmpscr);
22592 278 dir=up;
22593 278 x=112;
22594 278 y=160;
22595
1/2
✓ Branch 0 taken 278 times.
✗ Branch 1 not taken.
278 if(didpit)
22596 {
22597 didpit=false;
22598 x=pitx;
22599 y=pity;
22600 }
22601
22602 278 reset_hookshot();
22603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(reposition_sword_postwarp)
22604 {
22605 weapon *swd=NULL;
22606 for(int32_t i=0; i<Lwpns.Count(); i++)
22607 {
22608 swd = (weapon*)Lwpns.spr(i);
22609
22610 if(swd->id == (attack==wSword ? wSword : wWand))
22611 {
22612 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22613 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22614 positionSword(swd,item_id);
22615 break;
22616 }
22617 }
22618 }
22619 278 stepforward(diagonalMovement?5:6, false);
22620 278 }
22621 else // item room
22622 {
22623 110 specialcave = ITEMCELLAR;
22624 110 map_bkgsfx(false);
22625 110 kill_enemy_sfx();
22626 110 draw_screen(tmpscr,false);
22627
22628 //unless the room is already dark, fade to black
22629
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 109 times.
110 if(!darkroom)
22630 {
22631 109 darkroom = true;
22632 109 fade(DMaps[currdmap].color,true,false);
22633 109 }
22634
22635 110 blackscr(30,true);
22636 110 loadscr(0,wdmap,currscr,down,false);
22637 110 loadscr(1,wdmap,homescr,-1,false);
22638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if ( dontdraw < 2 ) { dontdraw=1; }
22639 110 draw_screen(tmpscr);
22640 110 fade(11,true,true);
22641 110 darkroom = false;
22642 110 dir=down;
22643 110 x=48;
22644 110 y=0;
22645
22646 // is this didpit check necessary?
22647
1/2
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
110 if(didpit)
22648 {
22649 didpit=false;
22650 x=pitx;
22651 y=pity;
22652 }
22653
22654 110 reset_hookshot();
22655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(reposition_sword_postwarp)
22656 {
22657 weapon *swd=NULL;
22658 for(int32_t i=0; i<Lwpns.Count(); i++)
22659 {
22660 swd = (weapon*)Lwpns.spr(i);
22661
22662 if(swd->id == (attack==wSword ? wSword : wWand))
22663 {
22664 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22665 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22666 positionSword(swd,item_id);
22667 break;
22668 }
22669 }
22670 }
22671 110 lighting(false, true);
22672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if ( dontdraw < 2 ) { dontdraw=0; }
22673 110 stepforward(diagonalMovement?16:18, false);
22674 }
22675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
388 if (get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC)) playLevelMusic();
22676 388 break;
22677 }
22678
22679 case wtPASS: // passageway
22680 {
22681 203 map_bkgsfx(false);
22682 203 kill_enemy_sfx();
22683 203 ALLOFF();
22684 //play sound
22685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
22686 203 homescr=currscr;
22687 203 currscr=0x81;
22688 203 specialcave = PASSAGEWAY;
22689 203 byte warpscr2 = wscr + DMaps[wdmap].xoff;
22690 203 draw_screen(tmpscr,false);
22691
22692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 if(!get_bit(quest_rules, qr_NEW_DARKROOM))
22693 {
22694
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 195 times.
203 if(!darkroom)
22695 195 fade(DMaps[currdmap].color,true,false);
22696
22697 203 darkroom=true;
22698 203 }
22699 203 blackscr(30,true);
22700 203 loadscr(0,wdmap,currscr,down,false);
22701 203 loadscr(1,wdmap,homescr,-1,false);
22702 //preloaded freeform combos
22703 203 ffscript_engine(true);
22704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 if ( dontdraw < 2 ) { dontdraw=1; }
22705 203 draw_screen(tmpscr);
22706 203 lighting(false, true);
22707 203 dir=down;
22708 203 x=48;
22709
22710
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 103 times.
203 if((homescr&15) > (warpscr2&15))
22711 {
22712 103 x=192;
22713 103 }
22714
22715
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 4 times.
203 if((homescr&15) == (warpscr2&15))
22716 {
22717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((currscr>>4) > (warpscr2>>4))
22718 {
22719 4 x=192;
22720 4 }
22721 4 }
22722
22723 // is this didpit check necessary?
22724
1/2
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
203 if(didpit)
22725 {
22726 didpit=false;
22727 x=pitx;
22728 y=pity;
22729 }
22730
22731 203 y=0;
22732 203 set_respawn_point();
22733 203 trySideviewLadder();
22734 203 reset_hookshot();
22735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 if(reposition_sword_postwarp)
22736 {
22737 weapon *swd=NULL;
22738 for(int32_t i=0; i<Lwpns.Count(); i++)
22739 {
22740 swd = (weapon*)Lwpns.spr(i);
22741
22742 if(swd->id == (attack==wSword ? wSword : wWand))
22743 {
22744 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22745 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22746 positionSword(swd,item_id);
22747 break;
22748 }
22749 }
22750 }
22751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203 times.
203 if ( dontdraw < 2 ) { dontdraw=0; }
22752 203 stepforward(diagonalMovement?16:18, false);
22753 203 newscr_clk=frame;
22754 203 activated_timed_warp=false;
22755 203 stepoutindex=index;
22756 203 stepoutscr = warpscr2;
22757 203 stepoutdmap = wdmap;
22758 203 stepoutwr=wrindex;
22759 }
22760 203 break;
22761
22762 case wtEXIT: // entrance/exit
22763 {
22764 317 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
22765 317 ALLOFF();
22766 317 music_stop();
22767 317 kill_sfx();
22768 317 blackscr(30,false);
22769 317 bool changedlevel = false;
22770 317 bool changeddmap = false;
22771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if(currdmap != wdmap)
22772 {
22773 317 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
22774 317 changeddmap = true;
22775 317 }
22776
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 300 times.
317 if(dlevel != DMaps[wdmap].level)
22777 {
22778 300 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
22779 300 changedlevel = true;
22780 300 }
22781 317 dlevel = DMaps[wdmap].level;
22782 317 currdmap = wdmap;
22783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if(changeddmap)
22784 {
22785 317 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
22786 317 }
22787
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 300 times.
317 if(changedlevel)
22788 {
22789 300 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
22790 300 }
22791
22792 317 currmap=DMaps[currdmap].map;
22793 317 init_dmap();
22794 317 update_subscreens(wdmap);
22795 317 loadfullpal();
22796 317 ringcolor(false);
22797 317 loadlvlpal(DMaps[currdmap].color);
22798 //lastentrance_dmap = currdmap;
22799 317 homescr = currscr = wscr + DMaps[currdmap].xoff;
22800 317 loadscr(0,currdmap,currscr,-1,overlay);
22801
22802
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
317 if((tmpscr->flags&fDARK) && !get_bit(quest_rules,qr_NEW_DARKROOM))
22803 {
22804
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(get_bit(quest_rules,qr_FADE))
22805 {
22806 interpolatedfade();
22807 }
22808 else
22809 {
22810 3 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
22811 }
22812
22813 3 darkroom=naturaldark=true;
22814 3 }
22815 else
22816 {
22817 314 darkroom=naturaldark=false;
22818 }
22819
22820 int32_t wrx,wry;
22821
22822
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 303 times.
317 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22823 {
22824 14 wrx=tmpscr->warpreturnx[0];
22825 14 wry=tmpscr->warpreturny[0];
22826 14 }
22827 else
22828 {
22829 303 wrx=tmpscr->warparrivalx;
22830 303 wry=tmpscr->warparrivaly;
22831 }
22832
22833
6/6
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 275 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 26 times.
✓ Branch 5 taken 291 times.
317 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
22834 {
22835
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 115 times.
291 if(dlevel)
22836 {
22837 176 lastentrance = currscr;
22838 176 }
22839 else
22840 {
22841 115 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
22842 }
22843
22844 291 lastentrance_dmap = wdmap;
22845 291 }
22846
22847
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 141 times.
317 if(dlevel)
22848 {
22849
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 169 times.
176 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
22850 {
22851 7 x=tmpscr->warpreturnx[wrindex];
22852 7 y=tmpscr->warpreturny[wrindex];
22853 7 }
22854 else
22855 {
22856 169 x=tmpscr->warparrivalx;
22857 169 y=tmpscr->warparrivaly;
22858 }
22859 176 }
22860 else
22861 {
22862 141 x=tmpscr->warpreturnx[wrindex];
22863 141 y=tmpscr->warpreturny[wrindex];
22864 }
22865
22866
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 3 times.
317 if(didpit)
22867 {
22868 3 didpit=false;
22869 3 x=pitx;
22870 3 y=pity;
22871 3 }
22872
22873 317 dir=down;
22874
22875
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 301 times.
317 if(x==0) dir=right;
22876
22877
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 306 times.
317 if(x==240) dir=left;
22878
22879
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 309 times.
317 if(y==0) dir=down;
22880
22881
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 189 times.
317 if(y==160) dir=up;
22882
22883
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 141 times.
317 if(dlevel)
22884 {
22885 // reset enemy kill counts
22886
2/2
✓ Branch 0 taken 22528 times.
✓ Branch 1 taken 176 times.
22704 for(int32_t i=0; i<128; i++)
22887 {
22888 22528 game->guys[(currmap*MAPSCRSNORMAL)+i] = 0;
22889 22528 game->maps[(currmap*MAPSCRSNORMAL)+i] &= ~mTMPNORET;
22890 22528 }
22891 176 }
22892
22893 317 markBmap(dir^1);
22894 //preloaded freeform combos
22895 317 ffscript_engine(true);
22896
22897 317 reset_hookshot();
22898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if(reposition_sword_postwarp)
22899 {
22900 weapon *swd=NULL;
22901 for(int32_t i=0; i<Lwpns.Count(); i++)
22902 {
22903 swd = (weapon*)Lwpns.spr(i);
22904
22905 if(swd->id == (attack==wSword ? wSword : wWand))
22906 {
22907 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
22908 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
22909 positionSword(swd,item_id);
22910 break;
22911 }
22912 }
22913 }
22914
22915
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 201 times.
317 if(isdungeon())
22916 {
22917 116 openscreen();
22918
2/4
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
116 if(get_bit(extra_rules, er_SHORTDGNWALK)==0 && get_bit(quest_rules, qr_SHORTDGNWALK)==0)
22919 116 stepforward(diagonalMovement?11:12, false);
22920 else
22921 // Didn't walk as far pre-1.93, and some quests depend on that
22922 stepforward(8, false);
22923 116 }
22924 else
22925 {
22926
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 178 times.
201 if(!COOLSCROLL)
22927 23 openscreen();
22928
22929 201 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
22930 201 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
22931 201 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
22932
22933
5/10
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 148 times.
✓ Branch 4 taken 148 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 148 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
201 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
22934 {
22935 53 reset_pal_cycling();
22936 53 putscr(scrollbuf,0,0,tmpscr);
22937 53 putscrdoors(scrollbuf,0,0,tmpscr);
22938 53 walkup(COOLSCROLL);
22939 53 }
22940
5/10
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 145 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 145 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
148 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
22941 {
22942 3 reset_pal_cycling();
22943 3 putscr(scrollbuf,0,0,tmpscr);
22944 3 putscrdoors(scrollbuf,0,0,tmpscr);
22945 3 walkdown2(COOLSCROLL);
22946 3 }
22947
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 13 times.
145 else if(COOLSCROLL)
22948 {
22949 132 openscreen();
22950 132 }
22951 }
22952
22953 317 show_subscreen_life=true;
22954 317 show_subscreen_numbers=true;
22955 317 playLevelMusic();
22956 317 currcset=DMaps[currdmap].color;
22957 317 dointro();
22958 317 set_respawn_point();
22959 317 trySideviewLadder();
22960
22961
2/2
✓ Branch 0 taken 1902 times.
✓ Branch 1 taken 317 times.
2219 for(int32_t i=0; i<6; i++)
22962 1902 visited[i]=-1;
22963
22964 317 break;
22965 }
22966
22967 case wtSCROLL: // scrolling warp
22968 {
22969 242 int32_t c = DMaps[currdmap].color;
22970 242 scrolling_map = currmap;
22971 242 currmap = DMaps[wdmap].map;
22972 242 update_subscreens(wdmap);
22973
22974 242 dlevel = DMaps[wdmap].level;
22975 //check if Hero has the map for the new location before updating the subscreen. ? -Z
22976 //This works only in one direction, if Hero had a map, to not having one.
22977 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
22978 242 update_subscreens(wdmap);
22979
22980 /*if ( has_item(itype_map, dlevel) )
22981 {
22982 //Blank the map during an intra-dmap scrolling warp.
22983 dlevel = -1; //a hack for the minimap. This works!! -Z
22984 }*/
22985
22986 // fix the scrolling direction, if it was a tile or instant warp
22987
2/4
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 242 times.
242 if(type==0 || type>=3)
22988 {
22989 sdir = dir;
22990 }
22991
22992 242 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
22993 //dlevel = DMaps[wdmap].level; //Fix dlevel and draw the map (end hack). -Z
22994
22995 242 reset_hookshot();
22996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242 times.
242 if(reposition_sword_postwarp)
22997 {
22998 weapon *swd=NULL;
22999 for(int32_t i=0; i<Lwpns.Count(); i++)
23000 {
23001 swd = (weapon*)Lwpns.spr(i);
23002
23003 if(swd->id == (attack==wSword ? wSword : wWand))
23004 {
23005 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23006 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23007 positionSword(swd,item_id);
23008 break;
23009 }
23010 }
23011 }
23012
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 196 times.
242 if(!intradmap)
23013 {
23014 196 homescr = currscr = wscr + DMaps[wdmap].xoff;
23015 196 init_dmap();
23016
23017 int32_t wrx,wry;
23018
23019
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 97 times.
196 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
23020 {
23021 99 wrx=tmpscr->warpreturnx[0];
23022 99 wry=tmpscr->warpreturny[0];
23023 99 }
23024 else
23025 {
23026 97 wrx=tmpscr->warparrivalx;
23027 97 wry=tmpscr->warparrivaly;
23028 }
23029
23030
7/8
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 99 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
✓ Branch 5 taken 124 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 66 times.
196 if(((wrx>0||wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))&&(!get_bit(quest_rules,qr_NOSCROLLCONTINUE))&&(!(tmpscr->flags6&fNOCONTINUEHERE)))
23031 {
23032
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 48 times.
66 if(dlevel)
23033 {
23034 18 lastentrance = currscr;
23035 18 }
23036 else
23037 {
23038 48 lastentrance = DMaps[currdmap].cont + DMaps[currdmap].xoff;
23039 }
23040
23041 66 lastentrance_dmap = wdmap;
23042 66 }
23043 196 }
23044
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 114 times.
242 if(DMaps[currdmap].color != c)
23045 {
23046 114 lighting(false, true);
23047 114 }
23048
23049 242 playLevelMusic();
23050 242 currcset=DMaps[currdmap].color;
23051 242 dointro();
23052 }
23053 242 break;
23054
23055 case wtWHISTLE: // whistle warp
23056 {
23057 38 scrolling_map = currmap;
23058 38 currmap = DMaps[wdmap].map;
23059 38 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
23060 38 reset_hookshot();
23061 38 currdmap=wdmap;
23062 38 dlevel=DMaps[currdmap].level;
23063 38 lighting(false, true);
23064 38 init_dmap();
23065
23066 38 playLevelMusic();
23067 38 currcset=DMaps[currdmap].color;
23068 38 dointro();
23069 38 action=inwind; FFCore.setHeroAction(inwind);
23070 int32_t wry;
23071
23072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
23073 wry=tmpscr->warpreturny[0];
23074 38 else wry=tmpscr->warparrivaly;
23075
23076 int32_t wrx;
23077
23078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
23079 wrx=tmpscr->warpreturnx[0];
23080 38 else wrx=tmpscr->warparrivalx;
23081
23082
7/14
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 38 times.
✓ Branch 10 taken 38 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 38 times.
✗ Branch 13 not taken.
76 Lwpns.add(new weapon((zfix)(index==left?240:index==right?0:wrx),(zfix)(index==down?0:index==up?160:wry),
23083
2/4
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
38 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1));
23084 38 whirlwind=255;
23085 38 whistleitem=-1;
23086 }
23087 38 break;
23088
23089 case wtIWARP:
23090 case wtIWARPBLK:
23091 case wtIWARPOPEN:
23092 case wtIWARPZAP:
23093 case wtIWARPWAVE: // insta-warps
23094 {
23095 529 bool old_192 = false;
23096
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 if (get_bit(quest_rules,qr_192b163_WARP))
23097 {
23098 if ( wtype == wtIWARPWAVE )
23099 {
23100 wtype = wtIWARPWAVE;
23101 old_192 = true;
23102 }
23103 if ( old_192 )
23104 {
23105 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
23106 didpit=false;
23107 update_subscreens();
23108 warp_sound = 0;
23109 is_warping = false;
23110 return false;
23111 }
23112 }
23113 //for determining whether to exit cave
23114 529 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23115 529 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23116 529 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23117
23118
8/8
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 463 times.
✓ Branch 4 taken 478 times.
✓ Branch 5 taken 15 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 469 times.
1020 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
23119
8/8
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 459 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 465 times.
✓ Branch 6 taken 457 times.
✓ Branch 7 taken 8 times.
478 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
23120
23121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483 times.
581 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
23122 {
23123 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
23124 483 bool wasswimming = (action == swimming);
23125 483 int32_t olddiveclk = diveclk;
23126 483 ALLOFF();
23127
23128
2/2
✓ Branch 0 taken 466 times.
✓ Branch 1 taken 17 times.
483 if(wasswimming)
23129 {
23130 17 Hero.SetSwim();
23131 17 diveclk = olddiveclk;
23132 17 }
23133
23134 483 kill_sfx();
23135 483 }
23136 //play sound
23137
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 42 times.
483 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
23138
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 424 times.
483 if(wtype==wtIWARPZAP)
23139 {
23140 59 zapout();
23141 59 }
23142
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 401 times.
424 else if(wtype==wtIWARPWAVE)
23143 {
23144 //only draw Hero if he's not in a cave -DD
23145 23 wavyout(!cavewarp);
23146 23 }
23147
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 153 times.
401 else if(wtype!=wtIWARP)
23148 {
23149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
153 bool b2 = COOLSCROLL&&cavewarp;
23150 153 blackscr(30,b2?false:true);
23151 153 }
23152
23153 483 int32_t c = DMaps[currdmap].color;
23154 483 bool changedlevel = false;
23155 483 bool changeddmap = false;
23156
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 311 times.
483 if(currdmap != wdmap)
23157 {
23158 311 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
23159 311 changeddmap = true;
23160 311 }
23161
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 137 times.
483 if(dlevel != DMaps[wdmap].level)
23162 {
23163 137 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
23164 137 changedlevel = true;
23165 137 }
23166 483 dlevel = DMaps[wdmap].level;
23167 483 currdmap = wdmap;
23168
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 311 times.
483 if(changeddmap)
23169 {
23170 311 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23171 311 }
23172
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 137 times.
483 if(changedlevel)
23173 {
23174 137 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23175 137 }
23176
23177 483 currmap = DMaps[currdmap].map;
23178 483 init_dmap();
23179 483 update_subscreens(wdmap);
23180
23181 483 ringcolor(false);
23182
23183
2/2
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 242 times.
483 if(DMaps[currdmap].color != c)
23184 242 loadlvlpal(DMaps[currdmap].color);
23185
23186 483 homescr = currscr = wscr + DMaps[currdmap].xoff;
23187
23188 483 lightingInstant(); // Also sets naturaldark
23189
23190 483 loadscr(0,currdmap,currscr,-1,overlay);
23191
23192 483 x = tmpscr->warpreturnx[wrindex];
23193 483 y = tmpscr->warpreturny[wrindex];
23194
23195
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 173 times.
483 if(didpit)
23196 {
23197 173 didpit=false;
23198 173 x=pitx;
23199 173 y=pity;
23200 173 }
23201
23202 483 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23203 483 type2 = combobuf[MAPCOMBO(x,y)].type;
23204 483 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23205
23206
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 73 times.
483 if(x==0) dir=right;
23207
23208
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 2 times.
483 if(x==240) dir=left;
23209
23210
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 21 times.
483 if(y==0) dir=down;
23211
23212
2/2
✓ Branch 0 taken 459 times.
✓ Branch 1 taken 24 times.
483 if(y==160) dir=up;
23213
23214 483 markBmap(dir^1);
23215
23216 483 int32_t checkwater = iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
23217
23218
10/16
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 12 times.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 12 times.
✓ Branch 15 taken 471 times.
495 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & ITEM_FLAG3)))
23219 {
23220 12 hopclk=0xFF;
23221 12 SetSwim();
23222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!IsSideSwim()) attackclk = charging = spins = 0;
23223 12 }
23224 else
23225 {
23226 471 action = none; FFCore.setHeroAction(none);
23227 }
23228 //preloaded freeform combos
23229 483 ffscript_engine(true);
23230
23231 483 putscr(scrollbuf,0,0,tmpscr);
23232 483 putscrdoors(scrollbuf,0,0,tmpscr);
23233
23234
10/10
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 464 times.
✓ Branch 4 taken 481 times.
✓ Branch 5 taken 17 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 465 times.
✓ Branch 8 taken 20 times.
✓ Branch 9 taken 36 times.
483 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23235 {
23236 56 reset_pal_cycling();
23237 56 putscr(scrollbuf,0,0,tmpscr);
23238 56 putscrdoors(scrollbuf,0,0,tmpscr);
23239 56 walkup(COOLSCROLL);
23240 56 }
23241
9/10
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 471 times.
✓ Branch 4 taken 481 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 467 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
501 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23242 {
23243 40 reset_pal_cycling();
23244 40 putscr(scrollbuf,0,0,tmpscr);
23245 40 putscrdoors(scrollbuf,0,0,tmpscr);
23246 40 walkdown2(COOLSCROLL);
23247 40 }
23248
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 422 times.
481 else if(wtype==wtIWARPZAP)
23249 {
23250 59 zapin();
23251 59 }
23252
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 399 times.
422 else if(wtype==wtIWARPWAVE)
23253 {
23254 23 wavyin();
23255 23 }
23256
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 73 times.
399 else if(wtype==wtIWARPOPEN)
23257 {
23258 73 openscreen();
23259 73 }
23260
1/2
✓ Branch 0 taken 537 times.
✗ Branch 1 not taken.
537 if(reposition_sword_postwarp)
23261 {
23262 weapon *swd=NULL;
23263 for(int32_t i=0; i<Lwpns.Count(); i++)
23264 {
23265 swd = (weapon*)Lwpns.spr(i);
23266
23267 if(swd->id == (attack==wSword ? wSword : wWand))
23268 {
23269 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23270 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23271 positionSword(swd,item_id);
23272 break;
23273 }
23274 }
23275 }
23276 537 show_subscreen_life=true;
23277 537 show_subscreen_numbers=true;
23278 537 playLevelMusic();
23279 537 currcset=DMaps[currdmap].color;
23280 537 dointro();
23281 537 set_respawn_point();
23282 537 trySideviewLadder();
23283 }
23284 537 break;
23285
23286
23287 case wtNOWARP:
23288 {
23289 37 bool old_192 = false;
23290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if (get_bit(quest_rules,qr_192b163_WARP))
23291 {
23292 wtype = wtIWARPWAVE;
23293 old_192 = true;
23294 }
23295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if ( old_192 )
23296 {
23297 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
23298 //for determining whether to exit cave
23299 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23300 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23301 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23302
23303 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
23304 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
23305
23306 if(!(tmpscr->flags3&fIWARPFULLSCREEN))
23307 {
23308 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
23309 bool wasswimming = (action == swimming);
23310 int32_t olddiveclk = diveclk;
23311 ALLOFF();
23312
23313 if(wasswimming)
23314 {
23315 Hero.SetSwim();
23316 diveclk = olddiveclk;
23317 }
23318
23319 kill_sfx();
23320 }
23321 //play sound
23322 if(warpsfx > 0) sfx(warpsfx,pan(x.getInt()));
23323 if(wtype==wtIWARPZAP)
23324 {
23325 zapout();
23326 }
23327 else if(wtype==wtIWARPWAVE)
23328 {
23329 //only draw Hero if he's not in a cave -DD
23330 wavyout(!cavewarp);
23331 }
23332 else if(wtype!=wtIWARP)
23333 {
23334 bool b2 = COOLSCROLL&&cavewarp;
23335 blackscr(30,b2?false:true);
23336 }
23337
23338 int32_t c = DMaps[currdmap].color;
23339 bool changedlevel = false;
23340 bool changeddmap = false;
23341 if(currdmap != wdmap)
23342 {
23343 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
23344 changeddmap = true;
23345 }
23346 if(dlevel != DMaps[wdmap].level)
23347 {
23348 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
23349 changedlevel = true;
23350 }
23351 dlevel = DMaps[wdmap].level;
23352 currdmap = wdmap;
23353 if(changeddmap)
23354 {
23355 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
23356 }
23357 if(changedlevel)
23358 {
23359 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
23360 }
23361 currmap = DMaps[currdmap].map;
23362 init_dmap();
23363 update_subscreens(wdmap);
23364
23365 ringcolor(false);
23366
23367 if(DMaps[currdmap].color != c)
23368 loadlvlpal(DMaps[currdmap].color);
23369
23370 homescr = currscr = wscr + DMaps[currdmap].xoff;
23371
23372 lightingInstant(); // Also sets naturaldark
23373
23374 loadscr(0,currdmap,currscr,-1,overlay);
23375
23376 x = tmpscr->warpreturnx[wrindex];
23377 y = tmpscr->warpreturny[wrindex];
23378
23379 if(didpit)
23380 {
23381 didpit=false;
23382 x=pitx;
23383 y=pity;
23384 }
23385
23386 type1 = combobuf[MAPCOMBO(x,y-16)].type;
23387 type2 = combobuf[MAPCOMBO(x,y)].type;
23388 type3 = combobuf[MAPCOMBO(x,y+16)].type;
23389
23390 if(x==0) dir=right;
23391
23392 if(x==240) dir=left;
23393
23394 if(y==0) dir=down;
23395
23396 if(y==160) dir=up;
23397
23398 markBmap(dir^1);
23399
23400 if(iswaterex(MAPCOMBO(x,y+8), currmap, currscr, -1, x,y+8) && _walkflag(x,y+8,0,SWITCHBLOCK_STATE) && current_item(itype_flippers))
23401 {
23402 hopclk=0xFF;
23403 SetSwim();
23404 if (!IsSideSwim()) attackclk = charging = spins = 0;
23405 }
23406 else
23407 {
23408 action = none;
23409 FFCore.setHeroAction(none);
23410 }
23411 //preloaded freeform combos
23412 ffscript_engine(true);
23413
23414 putscr(scrollbuf,0,0,tmpscr);
23415 putscrdoors(scrollbuf,0,0,tmpscr);
23416
23417 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23418 {
23419 reset_pal_cycling();
23420 putscr(scrollbuf,0,0,tmpscr);
23421 putscrdoors(scrollbuf,0,0,tmpscr);
23422 walkup(COOLSCROLL);
23423 }
23424 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23425 {
23426 reset_pal_cycling();
23427 putscr(scrollbuf,0,0,tmpscr);
23428 putscrdoors(scrollbuf,0,0,tmpscr);
23429 walkdown2(COOLSCROLL);
23430 }
23431 else if(wtype==wtIWARPZAP)
23432 {
23433 zapin();
23434 }
23435 else if(wtype==wtIWARPWAVE)
23436 {
23437 wavyin();
23438 }
23439 else if(wtype==wtIWARPOPEN)
23440 {
23441 openscreen();
23442 }
23443 if(reposition_sword_postwarp)
23444 {
23445 weapon *swd=NULL;
23446 for(int32_t i=0; i<Lwpns.Count(); i++)
23447 {
23448 swd = (weapon*)Lwpns.spr(i);
23449
23450 if(swd->id == (attack==wSword ? wSword : wWand))
23451 {
23452 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23453 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23454 positionSword(swd,item_id);
23455 break;
23456 }
23457 }
23458 }
23459 show_subscreen_life=true;
23460 show_subscreen_numbers=true;
23461 playLevelMusic();
23462 currcset=DMaps[currdmap].color;
23463 dointro();
23464 set_respawn_point();
23465 trySideviewLadder();
23466 break;
23467 }
23468 else
23469 {
23470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(reposition_sword_postwarp)
23471 {
23472 weapon *swd=NULL;
23473 for(int32_t i=0; i<Lwpns.Count(); i++)
23474 {
23475 swd = (weapon*)Lwpns.spr(i);
23476
23477 if(swd->id == (attack==wSword ? wSword : wWand))
23478 {
23479 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23480 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23481 positionSword(swd,item_id);
23482 break;
23483 }
23484 }
23485 }
23486 37 didpit=false;
23487 37 update_subscreens();
23488 37 warp_sound = 0;
23489 37 is_warping = false;
23490 37 return false;
23491 }
23492 }
23493 default:
23494 didpit=false;
23495 update_subscreens();
23496 warp_sound = 0;
23497 is_warping = false;
23498 if(reposition_sword_postwarp)
23499 {
23500 weapon *swd=NULL;
23501 for(int32_t i=0; i<Lwpns.Count(); i++)
23502 {
23503 swd = (weapon*)Lwpns.spr(i);
23504
23505 if(swd->id == (attack==wSword ? wSword : wWand))
23506 {
23507 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23508 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23509 positionSword(swd,item_id);
23510 break;
23511 }
23512 }
23513 }
23514 return false;
23515 }
23516
23517
23518
23519 // Stop Hero from drowning!
23520
5/6
✓ Branch 0 taken 1671 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 1671 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 1617 times.
1725 if(action==drowning || action==lavadrowning || action==sidedrowning)
23521 {
23522 108 drownclk=0;
23523 108 drownclk=0;
23524 108 action=none; FFCore.setHeroAction(none);
23525 108 }
23526
23527 1617 int32_t checkwater = iswaterex(MAPCOMBO(x,y+(bigHitbox?8:12)), currmap, currscr, -1, x,y+(bigHitbox?8:12));
23528 // But keep him swimming if he ought to be!
23529 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
23530
9/12
✓ Branch 0 taken 1665 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 1639 times.
✓ Branch 3 taken 26 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 26 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 26 times.
✓ Branch 10 taken 1710 times.
✓ Branch 11 taken 15 times.
1643 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,SWITCHBLOCK_STATE) || get_bit(quest_rules,qr_DROWN))
23531 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
23532
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
26 && (action!=inwind))
23533 {
23534 15 hopclk=0xFF;
23535 15 SetSwim();
23536 15 }
23537
23538 1725 newscr_clk=frame;
23539 1725 activated_timed_warp=false;
23540 1725 eat_buttons();
23541
23542
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 1423 times.
1725 if(wtype!=wtIWARP)
23543 1423 attackclk=0;
23544
23545 1725 didstuff=0;
23546 1725 usecounts.clear();
23547 1725 map_bkgsfx(true);
23548 1725 loadside=dir^1;
23549 1725 whistleclk=-1;
23550
23551
3/4
✓ Branch 0 taken 1671 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
1725 if((z>0 || fakez>0) && isSideViewHero())
23552 {
23553 y-=z;
23554 y-=fakez;
23555 fakez=0;
23556 z=0;
23557 }
23558
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 1555 times.
1725 else if(!isSideViewHero())
23559 {
23560 1555 fall=0;
23561 1555 fakefall=0;
23562 1555 }
23563
23564 // If warping between top-down and sideview screens,
23565 // fix enemies that are carried over by Full Screen Warp
23566 1725 const bool tmpscr_is_sideview = isSideViewHero();
23567
23568
4/4
✓ Branch 0 taken 1558 times.
✓ Branch 1 taken 167 times.
✓ Branch 2 taken 1528 times.
✓ Branch 3 taken 30 times.
1725 if(!wasSideview && tmpscr_is_sideview)
23569 {
23570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 for(int32_t i=0; i<guys.Count(); i++)
23571 {
23572 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
23573 {
23574 guys.spr(i)->y -= guys.spr(i)->z;
23575 guys.spr(i)->y -= guys.spr(i)->fakez;
23576 guys.spr(i)->z = 0;
23577 guys.spr(i)->fakez = 0;
23578 }
23579
23580 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23581 guys.spr(i)->yofs += 2;
23582 }
23583 30 }
23584
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 1582 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 27 times.
1695 else if(wasSideview && !tmpscr_is_sideview)
23585 {
23586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t i=0; i<guys.Count(); i++)
23587 {
23588 if(((enemy*)guys.spr(i))->family!=eeTRAP && ((enemy*)guys.spr(i))->family!=eeSPINTILE)
23589 guys.spr(i)->yofs -= 2;
23590 }
23591 27 }
23592
23593
6/6
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 705 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 840 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 55 times.
1725 if((DMaps[currdmap].type&dmfCONTINUE) || (currdmap==0&&get_bit(quest_rules, qr_DMAP_0_CONTINUE_BUG)))
23594 {
23595
2/2
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 620 times.
830 if(dlevel)
23596 {
23597 int32_t wrx,wry;
23598
23599
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 181 times.
208 if(get_bit(quest_rules,qr_NOARRIVALPOINT))
23600 {
23601 27 wrx=tmpscr->warpreturnx[0];
23602 27 wry=tmpscr->warpreturny[0];
23603 27 }
23604 else
23605 {
23606 181 wrx=tmpscr->warparrivalx;
23607 181 wry=tmpscr->warparrivaly;
23608 }
23609
23610
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
208 if((wtype == wtEXIT)
23611
7/10
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 147 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
208 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_bit(quest_rules,qr_WARPSIGNOREARRIVALPOINT)))))
23612 {
23613
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
57 if(!(wtype==wtSCROLL)||!(get_bit(quest_rules,qr_NOSCROLLCONTINUE)))
23614 {
23615 57 game->set_continue_scrn(homescr);
23616 //Z_message("continue_scrn = %02X e/e\n",game->get_continue_scrn());
23617 57 }
23618 else if(currdmap != game->get_continue_dmap())
23619 {
23620 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23621 }
23622 57 }
23623 else
23624 {
23625
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15 times.
151 if(currdmap != game->get_continue_dmap())
23626 {
23627 15 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23628 //Z_message("continue_scrn = %02X dlevel\n",game->get_continue_scrn());
23629 15 }
23630 }
23631 208 }
23632 else
23633 {
23634 620 game->set_continue_scrn(DMaps[currdmap].cont + DMaps[currdmap].xoff);
23635 //Z_message("continue_scrn = %02X\n !dlevel\n",game->get_continue_scrn());
23636 }
23637
23638 828 game->set_continue_dmap(currdmap);
23639 828 lastentrance_dmap = currdmap;
23640 828 lastentrance = game->get_continue_scrn();
23641 //Z_message("continue_map = %d\n",game->get_continue_dmap());
23642 828 }
23643
23644
1/2
✓ Branch 0 taken 1723 times.
✗ Branch 1 not taken.
1723 if(tmpscr->flags4&fAUTOSAVE)
23645 {
23646 save_game(true,0);
23647 }
23648
23649
2/2
✓ Branch 0 taken 1711 times.
✓ Branch 1 taken 12 times.
1723 if(tmpscr->flags6&fCONTINUEHERE)
23650 {
23651 12 lastentrance_dmap = currdmap;
23652 12 lastentrance = homescr;
23653 12 }
23654
23655 1723 update_subscreens();
23656 1723 verifyBothWeapons();
23657
23658
2/2
✓ Branch 0 taken 1335 times.
✓ Branch 1 taken 388 times.
1723 if(wtype==wtCAVE)
23659 {
23660
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 110 times.
388 if(DMaps[currdmap].flags&dmfGUYCAVES)
23661 556 Z_eventlog("Entered %s containing %s.\n",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
23662 278 (char *)moduledata.roomtype_names[tmpscr[1].room]);
23663 else
23664 110 Z_eventlog("Entered %s.",DMaps[currdmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
23665 388 }
23666 2670 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", currdmap, DMaps[currdmap].name,currscr,
23667
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1080 times.
2415 wtype==wtPASS ? "Passageway" :
23668
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 763 times.
1843 wtype==wtEXIT ? "Entrance/Exit" :
23669
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 521 times.
763 wtype==wtSCROLL ? "Scrolling Warp" :
23670 521 wtype==wtWHISTLE ? "Whistle Warp" :
23671 "Insta-Warp");
23672
23673 1723 eventlog_mapflags();
23674
1/2
✓ Branch 0 taken 1723 times.
✗ Branch 1 not taken.
1723 if(reposition_sword_postwarp)
23675 {
23676 weapon *swd=NULL;
23677 for(int32_t i=0; i<Lwpns.Count(); i++)
23678 {
23679 swd = (weapon*)Lwpns.spr(i);
23680
23681 if(swd->id == (attack==wSword ? wSword : wWand))
23682 {
23683 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
23684 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].family==itype) ? directWpn : current_item_id(itype);
23685 positionSword(swd,item_id);
23686 break;
23687 }
23688 }
23689 }
23690 1723 FFCore.init_combo_doscript();
23691
4/4
✓ Branch 0 taken 723 times.
✓ Branch 1 taken 1000 times.
✓ Branch 2 taken 671 times.
✓ Branch 3 taken 52 times.
1723 if (!intradmap || get_bit(quest_rules, qr_WARPS_RESTART_DMAPSCRIPT))
23692 {
23693 1671 FFScript::deallocateAllArrays(SCRIPT_DMAP, olddmap);
23694 1671 FFCore.initZScriptDMapScripts();
23695 1671 FFCore.initZScriptActiveSubscreenScript();
23696 1671 }
23697 1723 is_warping = false;
23698 1723 return true;
23699 1760 }
23700
23701 244 void HeroClass::exitcave()
23702 {
23703 244 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
23704 244 currscr=homescr;
23705 244 loadscr(0,currdmap,currscr,255,false); // bogus direction
23706 244 x = tmpscr->warpreturnx[0];
23707 244 y = tmpscr->warpreturny[0];
23708
23709
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(didpit)
23710 {
23711 didpit=false;
23712 x=pitx;
23713 y=pity;
23714 }
23715
23716
2/2
✓ Branch 0 taken 232 times.
✓ Branch 1 taken 12 times.
244 if(x+y == 0)
23717 12 x = y = 80;
23718
23719 244 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
23720 244 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
23721 244 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
23722
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 207 times.
471 bool b = COOLSCROLL &&
23723
4/4
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 178 times.
207 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
23724
4/4
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 178 times.
178 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
23725
4/4
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 160 times.
178 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
23726
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 165 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 5 times.
160 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
23727 264 ALLOFF();
23728 264 blackscr(30,b?false:true);
23729 264 ringcolor(false);
23730 264 loadlvlpal(DMaps[currdmap].color);
23731 264 lighting(false, true);
23732 264 music_stop();
23733 264 kill_sfx();
23734 264 putscr(scrollbuf,0,0,tmpscr);
23735 264 putscrdoors(scrollbuf,0,0,tmpscr);
23736
23737
9/10
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 193 times.
✓ Branch 4 taken 198 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 193 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
264 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
23738 {
23739 56 walkup(COOLSCROLL);
23740 56 }
23741
9/10
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 175 times.
✓ Branch 4 taken 180 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 175 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
198 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
23742 {
23743 18 walkdown2(COOLSCROLL);
23744 18 }
23745
23746 254 show_subscreen_life=true;
23747 254 show_subscreen_numbers=true;
23748 254 playLevelMusic();
23749 254 currcset=DMaps[currdmap].color;
23750 254 dointro();
23751 254 newscr_clk=frame;
23752 254 activated_timed_warp=false;
23753 254 dir=down;
23754 254 set_respawn_point();
23755 254 eat_buttons();
23756 254 didstuff=0;
23757 254 usecounts.clear();
23758 254 map_bkgsfx(true);
23759 254 loadside=dir^1;
23760 254 }
23761
23762
23763 4565 void HeroClass::stepforward(int32_t steps, bool adjust)
23764 {
23765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4565 times.
4565 if ( FFCore.nostepforward ) return;
23766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4565 times.
4565 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
23767 4565 zfix tx=x; //temp x
23768 4565 zfix ty=y; //temp y
23769 4565 zfix tstep(0); //temp single step distance
23770 4565 zfix s(0); //calculated step distance for all steps
23771 4565 z3step=2;
23772 4565 int32_t sh=shiftdir;
23773 4565 shiftdir=-1;
23774
23775
2/2
✓ Branch 0 taken 79894 times.
✓ Branch 1 taken 4565 times.
84459 for(int32_t i=steps; i>0; --i)
23776 {
23777
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 79883 times.
79894 if(diagonalMovement)
23778 {
23779
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23780 {
23781 11 tstep = 1.5;
23782 11 }
23783 else
23784 {
23785 tstep=z3step;
23786 z3step=(z3step%2)+1;
23787 }
23788 11 }
23789 else
23790 {
23791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79883 times.
79883 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT))
23792 {
23793 tstep = 1.5;
23794 }
23795 else
23796 {
23797
2/2
✓ Branch 0 taken 45095 times.
✓ Branch 1 taken 34788 times.
79883 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
23798
23799
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 25053 times.
✓ Branch 2 taken 20042 times.
✓ Branch 3 taken 15272 times.
✓ Branch 4 taken 19516 times.
79883 switch(dir)
23800 {
23801 case up:
23802 25053 ty-=tstep;
23803 25053 break;
23804
23805 case down:
23806 20042 ty+=tstep;
23807 20042 break;
23808
23809 case left:
23810 15272 tx-=tstep;
23811 15272 break;
23812
23813 case right:
23814 19516 tx+=tstep;
23815 19516 break;
23816 }
23817 }
23818 }
23819
23820 79894 s+=tstep;
23821 79894 }
23822
23823 4565 z3step=2;
23824
23825 4565 x = x.getInt();
23826 4565 y = y.getInt();
23827
2/2
✓ Branch 0 taken 84388 times.
✓ Branch 1 taken 4565 times.
88953 while(s>=0)
23828 {
23829
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 84376 times.
84388 if(diagonalMovement)
23830 {
23831
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
12 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23832 {
23833 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23834 {
23835 walkable = false;
23836 shiftdir = -1;
23837 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23838 switch(tdir)
23839 {
23840 case left:
23841 --x;
23842 break;
23843 case right:
23844 ++x;
23845 break;
23846 case up:
23847 --y;
23848 break;
23849 case down:
23850 ++y;
23851 break;
23852 }
23853 }
23854 else
23855 {
23856 walkable=false;
23857 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23858 move(dir, 150);
23859 }
23860 }
23861 else
23862 {
23863
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23864 {
23865 12 s-=1.5;
23866 12 }
23867 else
23868 {
23869 s-=z3step;
23870 }
23871 12 walkable=true;
23872 12 move(dir, 150);
23873 }
23874
23875 12 shiftdir=-1;
23876 12 }
23877 else
23878 {
23879
3/6
✓ Branch 0 taken 47714 times.
✓ Branch 1 taken 36662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 84376 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84376 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
23880 {
23881 walkable=false;
23882 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
23883 switch(tdir)
23884 {
23885 case left:
23886 --x;
23887 break;
23888 case right:
23889 ++x;
23890 break;
23891 case up:
23892 --y;
23893 break;
23894 case down:
23895 ++y;
23896 break;
23897 }
23898 }
23899 else
23900 {
23901
2/4
✓ Branch 0 taken 84376 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84376 times.
84376 if(get_bit(quest_rules, qr_NEW_HERO_MOVEMENT) || IsSideSwim())
23902 {
23903 s-=1.5;
23904 }
23905
2/2
✓ Branch 0 taken 47714 times.
✓ Branch 1 taken 36662 times.
84376 else if(dir<left)
23906 {
23907 47714 s-=lsteps[y.getInt()&7];
23908 47714 }
23909 else
23910 {
23911 36662 s-=lsteps[x.getInt()&7];
23912 }
23913
23914 84376 move(dir, 150);
23915 }
23916 }
23917
23918
2/2
✓ Branch 0 taken 79823 times.
✓ Branch 1 taken 4565 times.
84388 if(s<0)
23919 {
23920 // Not quite sure how this is actually supposed to work.
23921 // There have to be two cases for each direction or Hero
23922 // either walks too far onto the screen or may get stuck
23923 // going through walk-through walls.
23924
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1657 times.
✓ Branch 2 taken 1032 times.
✓ Branch 3 taken 808 times.
✓ Branch 4 taken 1068 times.
4565 switch(dir)
23925 {
23926 case up:
23927
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 1552 times.
1657 if(y<8) // Leaving the screen
23928 105 y+=s;
23929 else // Entering the screen
23930 1552 y-=s;
23931
23932 1657 break;
23933
23934 case down:
23935
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 944 times.
1032 if(y>152)
23936 88 y-=s;
23937 else
23938 944 y+=s;
23939
23940 1032 break;
23941
23942 case left:
23943
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 732 times.
808 if(x<8)
23944 76 x+=s;
23945 else
23946 732 x-=s;
23947
23948 808 break;
23949
23950 case right:
23951
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 976 times.
1068 if(x>=232)
23952 92 x-=s;
23953 else
23954 976 x+=s;
23955
23956 1068 break;
23957 }
23958 4565 }
23959
23960
23961 84388 draw_screen(tmpscr);
23962
1/2
✓ Branch 0 taken 84388 times.
✗ Branch 1 not taken.
84388 if (canSideviewLadder()) setOnSideviewLadder(true);
23963 84388 advanceframe(true);
23964
23965
1/2
✓ Branch 0 taken 84388 times.
✗ Branch 1 not taken.
84388 if(Quit)
23966 return;
23967 }
23968
4/4
✓ Branch 0 taken 3497 times.
✓ Branch 1 taken 1068 times.
✓ Branch 2 taken 1032 times.
✓ Branch 3 taken 2465 times.
4565 if(dir==right||dir==down)
23969 {
23970 2100 x=int32_t(x);
23971 2100 y=int32_t(y);
23972 2100 }
23973 else
23974 {
23975 2465 x = x.getInt();
23976 2465 y = y.getInt();
23977 }
23978 4565 set_respawn_point();
23979 4565 draw_screen(tmpscr);
23980 4565 eat_buttons();
23981 4565 shiftdir=sh;
23982 4565 }
23983
23984 142 void HeroClass::walkdown(bool opening) //entering cave
23985 {
23986
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 113 times.
142 if(opening)
23987 {
23988 113 close_black_opening(x+8, y+8+playing_field_offset, false);
23989 113 }
23990
23991 142 hclk=0;
23992 142 stop_item_sfx(itype_brang);
23993 142 sfx(WAV_STAIRS,pan(x.getInt()));
23994 142 clk=0;
23995 // int32_t cmby=(y.getInt()&0xF0)+16;
23996 // Fix Hero's position to the grid
23997 142 y=y.getInt()&0xF0;
23998 142 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
23999 142 attack=wNone;
24000 142 attackid=-1;
24001 142 reset_swordcharge();
24002 142 climb_cover_x=x.getInt()&0xF0;
24003 142 climb_cover_y=(y.getInt()&0xF0)+16;
24004
24005 142 guys.clear();
24006 142 chainlinks.clear();
24007 142 Lwpns.clear();
24008 142 Ewpns.clear();
24009 142 items.clear();
24010
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 9088 times.
9230 for(int32_t i=0; i<64; i++)
24011 {
24012 9088 herostep();
24013
24014
2/4
✓ Branch 0 taken 9088 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9088 times.
9088 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24015 hero_count=(hero_count+1)%16;
24016
24017
2/2
✓ Branch 0 taken 6816 times.
✓ Branch 1 taken 2272 times.
9088 if((i&3)==3)
24018 2272 ++y;
24019
24020 9088 draw_screen(tmpscr);
24021 9088 advanceframe(true);
24022
24023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9088 times.
9088 if(Quit)
24024 break;
24025 9088 }
24026
24027 142 action=none; FFCore.setHeroAction(none);
24028 142 }
24029
24030 21 void HeroClass::walkdown2(bool opening) //exiting cave 2
24031 {
24032 21 int32_t type = combobuf[MAPCOMBO(x,y)].type;
24033
24034
24035 // Fix Hero's position to the grid
24036 21 y=y.getInt()&0xF0;
24037
24038
2/6
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
24039 y -= 16;
24040
24041 21 climb_cover_x=x.getInt()&0xF0;
24042 21 climb_cover_y=y.getInt()&0xF0;
24043
24044 21 dir=down;
24045 21 z=fakez=fall=fakefall=0;
24046
24047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(opening)
24048 {
24049 21 open_black_opening(x+8, y+8+playing_field_offset+16, false);
24050 21 }
24051
24052 21 hclk=0;
24053 21 stop_item_sfx(itype_brang);
24054 21 sfx(WAV_STAIRS,pan(x.getInt()));
24055 21 clk=0;
24056 21 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
24057 21 attack=wNone;
24058 21 attackid=-1;
24059 21 reset_swordcharge();
24060
24061 21 guys.clear();
24062 21 chainlinks.clear();
24063 21 Lwpns.clear();
24064 21 Ewpns.clear();
24065 21 items.clear();
24066
24067
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1344 times.
1365 for(int32_t i=0; i<64; i++)
24068 {
24069 1344 herostep();
24070
24071
2/4
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1344 times.
1344 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24072 hero_count=(hero_count+1)%16;
24073
24074
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 if((i&3)==3)
24075 336 ++y;
24076
24077 1344 draw_screen(tmpscr);
24078 1344 advanceframe(true);
24079
24080
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(Quit)
24081 break;
24082 1344 }
24083
24084
24085 21 action=none; FFCore.setHeroAction(none);
24086 21 }
24087
24088 111 void HeroClass::walkup(bool opening) //exiting cave
24089 {
24090 111 int32_t type = combobuf[MAPCOMBO(x,y)].type;
24091
24092
4/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 107 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
111 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
24093 y+=16;
24094
24095 // Fix Hero's position to the grid
24096 111 y=y.getInt()&0xF0;
24097 111 z=fakez=fall=fakefall=0;
24098
24099
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 89 times.
111 if(opening)
24100 {
24101 89 open_black_opening(x+8, y+8+playing_field_offset-16, false);
24102 89 }
24103
24104 111 hclk=0;
24105 111 stop_item_sfx(itype_brang);
24106 111 sfx(WAV_STAIRS,pan(x.getInt()));
24107 111 dir=down;
24108 111 clk=0;
24109 // int32_t cmby=y.getInt()&0xF0;
24110 111 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
24111 111 attack=wNone;
24112 111 attackid=-1;
24113 111 reset_swordcharge();
24114 111 climb_cover_x=x.getInt()&0xF0;
24115 111 climb_cover_y=y.getInt()&0xF0;
24116
24117 111 guys.clear();
24118 111 chainlinks.clear();
24119 111 Lwpns.clear();
24120 111 Ewpns.clear();
24121 111 items.clear();
24122
24123
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 7104 times.
7215 for(int32_t i=0; i<64; i++)
24124 {
24125 7104 herostep();
24126
24127
2/4
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7104 times.
7104 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24128 hero_count=(hero_count+1)%16;
24129
24130
2/2
✓ Branch 0 taken 5328 times.
✓ Branch 1 taken 1776 times.
7104 if((i&3)==0)
24131 1776 --y;
24132
24133 7104 draw_screen(tmpscr);
24134 7104 advanceframe(true);
24135
24136
1/2
✓ Branch 0 taken 7104 times.
✗ Branch 1 not taken.
7104 if(Quit)
24137 break;
24138 7104 }
24139 111 map_bkgsfx(true);
24140 111 loadside=dir^1;
24141 111 action=none; FFCore.setHeroAction(none);
24142 111 }
24143
24144 103 void HeroClass::walkup2(bool opening) //entering cave2
24145 {
24146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(opening)
24147 {
24148 103 close_black_opening(x+8, y+8+playing_field_offset, false);
24149 103 }
24150
24151 103 hclk=0;
24152 103 stop_item_sfx(itype_brang);
24153 103 sfx(WAV_STAIRS,pan(x.getInt()));
24154 103 dir=up;
24155 103 clk=0;
24156 // int32_t cmby=y.getInt()&0xF0;
24157 103 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
24158 103 attack=wNone;
24159 103 attackid=-1;
24160 103 reset_swordcharge();
24161 103 climb_cover_x=x.getInt()&0xF0;
24162 103 climb_cover_y=(y.getInt()&0xF0)-16;
24163
24164 103 guys.clear();
24165 103 chainlinks.clear();
24166 103 Lwpns.clear();
24167 103 Ewpns.clear();
24168 103 items.clear();
24169
24170
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 6592 times.
6695 for(int32_t i=0; i<64; i++)
24171 {
24172 6592 herostep();
24173
24174
2/4
✓ Branch 0 taken 6592 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6592 times.
6592 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
24175 hero_count=(hero_count+1)%16;
24176
24177
2/2
✓ Branch 0 taken 4944 times.
✓ Branch 1 taken 1648 times.
6592 if((i&3)==0)
24178 1648 --y;
24179
24180 6592 draw_screen(tmpscr);
24181 6592 advanceframe(true);
24182
24183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6592 times.
6592 if(Quit)
24184 break;
24185 6592 }
24186 103 map_bkgsfx(true);
24187 103 loadside=dir^1;
24188 103 action=none; FFCore.setHeroAction(none);
24189 103 }
24190
24191 299 void HeroClass::stepout() // Step out of item cellars and passageways
24192 {
24193 299 int32_t sc = specialcave; // This gets erased by ALLOFF()
24194 299 ALLOFF();
24195 299 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
24196 299 map_bkgsfx(false);
24197 299 kill_enemy_sfx();
24198 299 draw_screen(tmpscr,false);
24199 299 fade(sc>=GUYCAVE?10:11,true,false);
24200 299 blackscr(30,true);
24201 299 ringcolor(false);
24202
24203
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 202 times.
✓ Branch 2 taken 139 times.
✓ Branch 3 taken 160 times.
299 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
24204 {
24205 160 currdmap=stepoutdmap;
24206 160 currmap=DMaps[currdmap].map;
24207 160 dlevel=DMaps[currdmap].level;
24208
24209 //we might have just left a passage, so be sure to update the CSet record -DD
24210 160 currcset=DMaps[currdmap].color;
24211
24212 160 init_dmap();
24213 160 homescr=stepoutscr;
24214 160 }
24215
24216 299 currscr=homescr;
24217 299 loadscr(0,currdmap,currscr,255,false); // bogus direction
24218 299 draw_screen(tmpscr,false);
24219
24220
3/4
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 6 times.
299 if(get_bit(quest_rules, qr_NEW_DARKROOM) || !(tmpscr->flags&fDARK))
24221 {
24222 293 darkroom = naturaldark = false;
24223 293 fade(DMaps[currdmap].color,true,true);
24224 293 }
24225 else
24226 {
24227 6 darkroom = naturaldark = true;
24228
24229
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if(get_bit(quest_rules,qr_FADE))
24230 {
24231 4 interpolatedfade();
24232 4 }
24233 else
24234 {
24235 2 loadfadepal((DMaps[currdmap].color)*pdLEVEL+poFADE3);
24236 }
24237 6 byte *si = colordata + CSET(DMaps[currdmap].color*pdLEVEL+poLEVEL)*3;
24238 6 si+=3*48;
24239
24240
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<16; i++)
24241 {
24242 96 RAMpal[CSET(9)+i] = _RGB(si);
24243 96 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
24244 96 si+=3;
24245 96 }
24246 }
24247
24248 299 x = tmpscr->warpreturnx[stepoutwr];
24249 299 y = tmpscr->warpreturny[stepoutwr];
24250
24251
1/2
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
299 if(didpit)
24252 {
24253 didpit=false;
24254 x=pitx;
24255 y=pity;
24256 }
24257
24258
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 284 times.
299 if(x+y == 0)
24259 15 x = y = 80;
24260
24261 299 dir=down;
24262
24263 299 set_respawn_point();
24264
24265 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
24266 299 int32_t type = combobuf[MAPCOMBO(tmpscr->warpreturnx[stepoutwr],tmpscr->warpreturny[stepoutwr])].type;
24267
24268
4/6
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 294 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
24269 {
24270 walkup(false);
24271 }
24272
4/6
✓ Branch 0 taken 299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 294 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
299 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
24273 {
24274 walkdown2(false);
24275 }
24276
24277 299 newscr_clk=frame;
24278 299 activated_timed_warp=false;
24279 299 didstuff=0;
24280 299 usecounts.clear();
24281 299 eat_buttons();
24282 299 markBmap(-1);
24283 299 map_bkgsfx(true);
24284
24285
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 27 times.
299 if(!get_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC))
24286 {
24287 27 music_stop();
24288 27 playLevelMusic();
24289 27 }
24290
1/2
✓ Branch 0 taken 272 times.
✗ Branch 1 not taken.
272 else if(get_bit(quest_rules,qr_SCREEN80_OWN_MUSIC))
24291 {
24292 playLevelMusic();
24293 }
24294
24295 299 loadside=dir^1;
24296 299 }
24297
24298 10005 bool HeroClass::nextcombo_wf(int32_t d2)
24299 {
24300
6/8
✓ Branch 0 taken 9954 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 9720 times.
✓ Branch 3 taken 234 times.
✓ Branch 4 taken 9720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 234 times.
✗ Branch 7 not taken.
10005 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
24301 10005 return false;
24302
24303 // assumes Hero is about to scroll screens
24304
24305 int32_t ns = nextscr(d2);
24306
24307 if(ns==0xFFFF)
24308 return false;
24309
24310 // want actual screen index, not game->maps[] index
24311 ns = (ns&127) + (ns>>7)*MAPSCRS;
24312
24313 int32_t cx = x;
24314 int32_t cy = y;
24315
24316 switch(d2)
24317 {
24318 case up:
24319 cy=160;
24320 break;
24321
24322 case down:
24323 cy=0;
24324 break;
24325
24326 case left:
24327 cx=240;
24328 break;
24329
24330 case right:
24331 cx=0;
24332 break;
24333 }
24334
24335 // check lower half of combo
24336 cy += 8;
24337
24338 // from MAPCOMBO()
24339 int32_t cmb = (cy&0xF0)+(cx>>4);
24340
24341 if(cmb>175)
24342 return true;
24343
24344 newcombo c = combobuf[TheMaps[ns].data[cmb]];
24345 bool dried = iswater_type(c.type) && DRIEDLAKE;
24346 bool swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24347 int32_t b=1;
24348
24349 if(cx&8) b<<=2;
24350
24351 if(cy&8) b<<=1;
24352
24353 if((c.walk&b) && !dried && !swim)
24354 return true;
24355
24356 // next block (i.e. cnt==2)
24357 if(!(cx&8))
24358 {
24359 b<<=2;
24360 }
24361 else
24362 {
24363 c = combobuf[TheMaps[ns].data[++cmb]];
24364 dried = iswater_type(c.type) && DRIEDLAKE;
24365 swim = iswater_type(c.type) && (current_item(itype_flippers)) && !dried;
24366 b=1;
24367
24368 if(cy&8)
24369 {
24370 b<<=1;
24371 }
24372 }
24373
24374 return (c.walk&b) ? !dried && !swim : false;
24375 10005 }
24376
24377 bool HeroClass::nextcombo_solid(int32_t d2)
24378 {
24379 if(toogam || currscr>=128)
24380 return false;
24381
24382 // assumes Hero is about to scroll screens
24383
24384 int32_t ns = nextscr(d2);
24385
24386 if(ns==0xFFFF)
24387 return false;
24388
24389 // want actual screen index, not game->maps[] index
24390 ns = (ns&127) + (ns>>7)*MAPSCRS;
24391 int32_t screen = (ns%MAPSCRS);
24392 int32_t map = (ns - screen) / MAPSCRS;
24393
24394 int32_t cx = x;
24395 int32_t cy = y;
24396
24397 switch(d2)
24398 {
24399 case up:
24400 cy=160;
24401 break;
24402
24403 case down:
24404 cy=0;
24405 break;
24406
24407 case left:
24408 cx=240;
24409 break;
24410
24411 case right:
24412 cx=0;
24413 break;
24414 }
24415
24416 if(d2==up) cy += 8;
24417
24418 if(d2==left||d2==right) cy+=bigHitbox?0:8;
24419
24420 int32_t initcx = cx;
24421 int32_t initcy = cy;
24422 // from MAPCOMBO()
24423
24424 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
24425 {
24426 cx = initcx;
24427 for(int32_t k=0; k<=(get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
24428 {
24429 int32_t cmb = (cy&0xF0)+(cx>>4);
24430
24431 if(cmb>175)
24432 {
24433 return true;
24434 }
24435
24436 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))];
24437
24438 int32_t b=1;
24439
24440 if(cx&8) b<<=2;
24441
24442 if(cy&8) b<<=1;
24443
24444 //bool bridgedetected = false;
24445
24446 int32_t walk = c.walk;
24447 if (get_bit(quest_rules, qr_SMARTER_SMART_SCROLL))
24448 {
24449 for (int32_t m = 0; m <= 1; m++)
24450 {
24451 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
24452 if (cmb.type == cBRIDGE)
24453 {
24454 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
24455 {
24456 int efflag = (cmb.walk & 0xF0)>>4;
24457 int newsolid = (cmb.walk & 0xF);
24458 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
24459 }
24460 else walk &= cmb.walk;
24461 }
24462 else walk |= cmb.walk;
24463 }
24464 }
24465 /*
24466 if (bridgedetected)
24467 {
24468 continue;
24469 }*/
24470
24471 //bool swim = iswater_type(c.type) && (current_item(itype_flippers) || action==rafting);
24472 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, get_bit(quest_rules, qr_SMARTER_SMART_SCROLL)), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
24473
24474 if((walk&b) && !swim)
24475 {
24476 return true;
24477 }
24478 }
24479
24480 /*
24481 #if 0
24482
24483 //
24484 // next block (i.e. cnt==2)
24485 if(!(cx&8))
24486 {
24487 b<<=2;
24488 }
24489 else
24490 {
24491 c = combobuf[TheMaps[ns].data[++cmb]];
24492 dried = iswater_type(c.type) && DRIEDLAKE;
24493 //swim = iswater_type(c.type) && (current_item(itype_flippers));
24494 b=1;
24495
24496 if(cy&8)
24497 {
24498 b<<=1;
24499 }
24500 }
24501
24502 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24503
24504 if((c.walk&b) && !dried && !swim)
24505 {
24506 return true;
24507 }
24508
24509 cx+=8;
24510
24511 if(cx&7)
24512 {
24513 if(!(cx&8))
24514 {
24515 b<<=2;
24516 }
24517 else
24518 {
24519 c = combobuf[TheMaps[ns].data[++cmb]];
24520 dried = iswater_type(c.type) && DRIEDLAKE;
24521 //swim = iswaterex(cmb, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24522 b=1;
24523
24524 if(cy&8)
24525 {
24526 b<<=1;
24527 }
24528 }
24529
24530 swim = iswaterex(c, map, screen, -1, cx+8, cy, true, false, true) && current_item(itype_flippers);
24531
24532 if((c.walk&b) && !dried && !swim)
24533 return true;
24534 }
24535
24536 #endif
24537 */
24538 }
24539
24540 return false;
24541 }
24542
24543 5152193 void HeroClass::checkscroll()
24544 {
24545 //DO NOT scroll if Hero is vibrating due to Farore's Wind effect -DD
24546
2/4
✓ Branch 0 taken 5152193 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5152193 times.
✗ Branch 3 not taken.
5152193 if(action == casting||action==sideswimcasting)
24547 return;
24548
24549
2/2
✓ Branch 0 taken 5138787 times.
✓ Branch 1 taken 13406 times.
5152193 if(toogam)
24550 {
24551
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(x<0 && (currscr&15)==0) x=0;
24552
24553
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 13386 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
13406 if(y<0 && currscr<16) y=0;
24554
24555
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 13391 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
13406 if(x>240 && (currscr&15)==15) x=240;
24556
24557
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13398 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
13406 if(y>160 && currscr>=112) y=160;
24558 13406 }
24559
24560
2/2
✓ Branch 0 taken 5149477 times.
✓ Branch 1 taken 2716 times.
5152193 if(y<0)
24561 {
24562 2716 bool doit=true;
24563 2716 y=0;
24564
24565
3/6
✓ Branch 0 taken 2716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2716 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2716 times.
2716 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24566 doit = false;
24567
24568
1/2
✓ Branch 0 taken 2716 times.
✗ Branch 1 not taken.
2716 if(nextcombo_wf(up))
24569 doit=false;
24570
24571
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2716 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2716 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(tmpscr->flags2&wfUP))
24572 {
24573 if(nextcombo_solid(up))
24574 doit=false;
24575 }
24576
24577
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2716 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2716 if(doit || action==inwind)
24578 {
24579
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 2417 times.
2716 if(currscr>=128)
24580 {
24581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if(specialcave >= GUYCAVE)
24582 exitcave();
24583 299 else stepout();
24584 299 }
24585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2417 times.
2417 else if(action==inwind)
24586 {
24587 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24588 {
24589 action=none; FFCore.setHeroAction(none);
24590 restart_level();
24591 }
24592 else
24593 {
24594 dowarp(2,up);
24595 }
24596 }
24597
3/6
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 2350 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2417 else if(tmpscr->flags2&wfUP && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24598 {
24599 67 sdir=up;
24600 67 dowarp(1,(tmpscr->sidewarpindex)&3);
24601 67 }
24602
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 2290 times.
2350 else if(!edge_of_dmap(up))
24603 {
24604 2290 scrolling_map = currmap;
24605 2290 scrollscr(up);
24606
24607
1/2
✓ Branch 0 taken 2290 times.
✗ Branch 1 not taken.
2290 if(tmpscr->flags4&fAUTOSAVE)
24608 {
24609 save_game(true,0);
24610 }
24611
24612
2/2
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 4 times.
2290 if(tmpscr->flags6&fCONTINUEHERE)
24613 {
24614 4 lastentrance_dmap = currdmap;
24615 4 lastentrance = homescr;
24616 4 }
24617 2290 }
24618 2716 }
24619 2716 }
24620
24621
2/2
✓ Branch 0 taken 5150278 times.
✓ Branch 1 taken 1915 times.
5152193 if(y>160)
24622 {
24623 1915 bool doit=true;
24624 1915 y=160;
24625
24626
4/6
✓ Branch 0 taken 1914 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1914 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1915 times.
1915 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24627 doit = false;
24628
24629
1/2
✓ Branch 0 taken 1915 times.
✗ Branch 1 not taken.
1915 if(nextcombo_wf(down))
24630 doit=false;
24631
24632
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1915 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1915 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfDOWN))
24633 {
24634 if(nextcombo_solid(down))
24635 doit=false;
24636 }
24637
24638
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1915 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1915 if(doit || action==inwind)
24639 {
24640
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 1717 times.
1915 if(currscr>=128)
24641 {
24642
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(specialcave >= GUYCAVE)
24643 198 exitcave();
24644 else stepout();
24645 198 }
24646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1717 times.
1717 else if(action==inwind)
24647 {
24648 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24649 {
24650 action=none; FFCore.setHeroAction(none);
24651 restart_level();
24652 }
24653 else
24654 {
24655 dowarp(2,down);
24656 }
24657 }
24658
3/6
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1717 else if(tmpscr->flags2&wfDOWN && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24659 {
24660 131 sdir=down;
24661 131 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
24662 131 }
24663
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1581 times.
1586 else if(!edge_of_dmap(down))
24664 {
24665 1581 scrolling_map = currmap;
24666 1581 scrollscr(down);
24667
24668
1/2
✓ Branch 0 taken 1581 times.
✗ Branch 1 not taken.
1581 if(tmpscr->flags4&fAUTOSAVE)
24669 {
24670 save_game(true,0);
24671 }
24672
24673
2/2
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 2 times.
1581 if(tmpscr->flags6&fCONTINUEHERE)
24674 {
24675 2 lastentrance_dmap = currdmap;
24676 2 lastentrance = homescr;
24677 2 }
24678 1581 }
24679 1915 }
24680 1915 }
24681
24682
2/2
✓ Branch 0 taken 5150148 times.
✓ Branch 1 taken 2045 times.
5152193 if(x<0)
24683 {
24684 2045 bool doit=true;
24685 2045 x=0;
24686
24687
3/6
✓ Branch 0 taken 2045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2045 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2045 times.
2045 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24688 doit = false;
24689
24690
1/2
✓ Branch 0 taken 2045 times.
✗ Branch 1 not taken.
2045 if(nextcombo_wf(left))
24691 doit=false;
24692
24693
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2045 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfLEFT))
24694 {
24695 if(nextcombo_solid(left))
24696 doit=false;
24697 }
24698
24699
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2045 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2045 if(doit || action==inwind)
24700 {
24701
1/2
✓ Branch 0 taken 2045 times.
✗ Branch 1 not taken.
2045 if(currscr>=128)
24702 {
24703 if(specialcave >= GUYCAVE)
24704 exitcave();
24705 else stepout();
24706 }
24707
24708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2045 times.
2045 if(action==inwind)
24709 {
24710 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24711 {
24712 action=none; FFCore.setHeroAction(none);
24713 restart_level();
24714 }
24715 else
24716 {
24717 dowarp(2,left);
24718 }
24719 }
24720
3/6
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 1957 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2045 else if(tmpscr->flags2&wfLEFT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24721 {
24722 88 sdir=left;
24723 88 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
24724 88 }
24725
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 1868 times.
1957 else if(!edge_of_dmap(left))
24726 {
24727 1868 scrolling_map = currmap;
24728 1868 scrollscr(left);
24729
24730
1/2
✓ Branch 0 taken 1868 times.
✗ Branch 1 not taken.
1868 if(tmpscr->flags4&fAUTOSAVE)
24731 {
24732 save_game(true,0);
24733 }
24734
24735
2/2
✓ Branch 0 taken 1860 times.
✓ Branch 1 taken 8 times.
1868 if(tmpscr->flags6&fCONTINUEHERE)
24736 {
24737 8 lastentrance_dmap = currdmap;
24738 8 lastentrance = homescr;
24739 8 }
24740 1868 }
24741 2045 }
24742 2045 }
24743
24744
2/2
✓ Branch 0 taken 5149804 times.
✓ Branch 1 taken 2389 times.
5152193 if(x>240)
24745 {
24746 2389 bool doit=true;
24747 2389 x=240;
24748
24749
3/6
✓ Branch 0 taken 2389 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2389 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2389 times.
2389 if((z > 0 || fakez > 0 || stomping) && get_bit(quest_rules, qr_NO_SCROLL_WHILE_IN_AIR))
24750 doit = false;
24751
24752
1/2
✓ Branch 0 taken 2389 times.
✗ Branch 1 not taken.
2389 if(nextcombo_wf(right))
24753 doit=false;
24754
24755
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 2389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2389 if(get_bit(quest_rules, qr_SMARTSCREENSCROLL)&&(!(tmpscr->flags&fMAZE))&&action!=inwind &&action!=scrolling &&!(tmpscr->flags2&wfRIGHT))
24756 {
24757 if(nextcombo_solid(right))
24758 doit=false;
24759 }
24760
24761
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2389 if(doit || action==inwind)
24762 {
24763
1/2
✓ Branch 0 taken 2389 times.
✗ Branch 1 not taken.
2389 if(currscr>=128)
24764 {
24765 if(specialcave >= GUYCAVE)
24766 exitcave();
24767 else stepout();
24768 }
24769
24770
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 2350 times.
2389 if(action==inwind)
24771 {
24772
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 38 times.
39 if(DMaps[currdmap].flags&dmfWHIRLWINDRET)
24773 {
24774 1 action=none; FFCore.setHeroAction(none);
24775 1 restart_level();
24776 1 }
24777 else
24778 {
24779 38 dowarp(2,right);
24780 }
24781 39 }
24782
3/6
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 2228 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2350 else if(tmpscr->flags2&wfRIGHT && (!(tmpscr->flags8&fMAZEvSIDEWARP) || checkmaze(tmpscr,false)))
24783 {
24784 122 sdir=right;
24785 122 dowarp(1,(tmpscr->sidewarpindex>>6)&3);
24786 122 }
24787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2228 times.
2228 else if(!edge_of_dmap(right))
24788 {
24789 2228 scrolling_map = currmap;
24790 2228 scrollscr(right);
24791
24792
1/2
✓ Branch 0 taken 2228 times.
✗ Branch 1 not taken.
2228 if(tmpscr->flags4&fAUTOSAVE)
24793 {
24794 save_game(true,0);
24795 }
24796
24797
2/2
✓ Branch 0 taken 2218 times.
✓ Branch 1 taken 10 times.
2228 if(tmpscr->flags6&fCONTINUEHERE)
24798 {
24799 10 lastentrance_dmap = currdmap;
24800 10 lastentrance = homescr;
24801 10 }
24802 2228 }
24803 2389 }
24804 2389 }
24805 5152193 }
24806
24807 // assumes current direction is in lastdir[3]
24808 // compares directions with scr->path and scr->exitdir
24809 23952 bool HeroClass::checkmaze(mapscr *scr, bool sound)
24810 {
24811
2/2
✓ Branch 0 taken 23626 times.
✓ Branch 1 taken 326 times.
23952 if(!(scr->flags&fMAZE))
24812 23626 return true;
24813
24814
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 288 times.
326 if(lastdir[3]==scr->exitdir)
24815 38 return true;
24816
24817
2/2
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 42 times.
498 for(int32_t i=0; i<4; i++)
24818
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 246 times.
456 if(lastdir[i]!=scr->path[i])
24819 246 return false;
24820
24821
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 21 times.
42 if(sound)
24822 21 sfx(scr->secretsfx);
24823
24824 42 return true;
24825 23952 }
24826
24827 15985 bool HeroClass::edge_of_dmap(int32_t side)
24828 {
24829
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 143 times.
15985 if(checkmaze(tmpscr,false)==false)
24830 143 return false;
24831
24832 // needs fixin'
24833 // should check dmap style
24834
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4554 times.
✓ Branch 2 taken 3121 times.
✓ Branch 3 taken 3772 times.
✓ Branch 4 taken 4395 times.
15842 switch(side)
24835 {
24836 case up:
24837 4554 return currscr<16;
24838
24839 case down:
24840 3121 return currscr>=112;
24841
24842 case left:
24843
2/2
✓ Branch 0 taken 3683 times.
✓ Branch 1 taken 89 times.
3772 if((currscr&15)==0)
24844 89 return true;
24845
24846
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 1697 times.
3683 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24847 // if(dlevel)
24848 1986 return (((currscr&15)-DMaps[currdmap].xoff)<=0);
24849
24850 1697 break;
24851
24852 case right:
24853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4395 times.
4395 if((currscr&15)==15)
24854 return true;
24855
24856
2/2
✓ Branch 0 taken 2513 times.
✓ Branch 1 taken 1882 times.
4395 if((DMaps[currdmap].type&dmfTYPE)!=dmOVERW)
24857 // if(dlevel)
24858 2513 return (((currscr&15)-DMaps[currdmap].xoff)>=7);
24859
24860 1882 break;
24861 }
24862
24863 3579 return false;
24864 15985 }
24865
24866 190 bool HeroClass::lookaheadraftflag(int32_t d2)
24867 {
24868 // Helper for scrollscr that gets next combo on next screen.
24869 // Can use destscr for scrolling warps,
24870 // but assumes currmap is correct.
24871
24872 190 int32_t cx = x;
24873 190 int32_t cy = y + 8;
24874
24875 190 bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24876 190 bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24877 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24878 //Applying this here, too. -Z
24879
24880
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 55 times.
190 switch(d2)
24881 {
24882 case up:
24883 50 cy=160;
24884 50 break;
24885
24886 case down:
24887 41 cy=0;
24888 41 break;
24889
24890 case left:
24891 44 cx=240;
24892 44 break;
24893
24894 case right:
24895 55 cx=0;
24896 55 break;
24897 }
24898
24899 190 int32_t combo = (cy&0xF0)+(cx>>4);
24900
24901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 if(combo>175)
24902 return 0;
24903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
190 return ( isRaftFlag(combobuf[tmpscr[0].data[combo]].flag) || isRaftFlag(tmpscr[0].sflag[combo]));
24904
24905 190 }
24906 8247 int32_t HeroClass::lookahead(int32_t d2) // Helper for scrollscr that gets next combo on next screen.
24907 {
24908 // Can use destscr for scrolling warps,
24909 // but assumes currmap is correct.
24910
24911 8247 int32_t cx = vbound(x,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
24912 8247 int32_t cy = vbound(y + 8,0,160);
24913 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24914 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24915 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24916
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2334 times.
✓ Branch 2 taken 1632 times.
✓ Branch 3 taken 1934 times.
✓ Branch 4 taken 2347 times.
8247 switch(d2)
24917 {
24918 case up:
24919 2334 cy=160;
24920 2334 break;
24921
24922 case down:
24923 1632 cy=0;
24924 1632 break;
24925
24926 case left:
24927 1934 cx=240;
24928 1934 break;
24929
24930 case right:
24931 2347 cx=0;
24932 2347 break;
24933 }
24934
24935 8247 int32_t combo = (cy&0xF0)+(cx>>4);
24936
24937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8247 times.
8247 if(combo>175)
24938 return 0;
24939
24940 8247 return tmpscr[0].data[combo]; // entire combo code
24941 8247 }
24942
24943 8247 int32_t HeroClass::lookaheadflag(int32_t d2)
24944 {
24945 // Helper for scrollscr that gets next combo on next screen.
24946 // Can use destscr for scrolling warps,
24947 // but assumes currmap is correct.
24948
24949 8247 int32_t cx = vbound(x,0,240);
24950 8247 int32_t cy = vbound(y + 8,0,160);
24951
24952 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24953 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
24954 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
24955 //Applying this here, too. -Z
24956
24957
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2334 times.
✓ Branch 2 taken 1632 times.
✓ Branch 3 taken 1934 times.
✓ Branch 4 taken 2347 times.
8247 switch(d2)
24958 {
24959 case up:
24960 2334 cy=160;
24961 2334 break;
24962
24963 case down:
24964 1632 cy=0;
24965 1632 break;
24966
24967 case left:
24968 1934 cx=240;
24969 1934 break;
24970
24971 case right:
24972 2347 cx=0;
24973 2347 break;
24974 }
24975
24976 8247 int32_t combo = (cy&0xF0)+(cx>>4);
24977
24978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8247 times.
8247 if(combo>175)
24979 return 0;
24980
24981
2/2
✓ Branch 0 taken 7983 times.
✓ Branch 1 taken 264 times.
8247 if(!tmpscr[0].sflag[combo])
24982 {
24983 7983 return combobuf[tmpscr[0].data[combo]].flag; // flag
24984 }
24985
24986 264 return tmpscr[0].sflag[combo]; // flag
24987 8247 }
24988
24989 //Bit of a messy kludge to give the correct Hero->X/Hero->Y in the script
24990 1114672 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
24991 {
24992 // For rafting (and possibly other esoteric things)
24993 // Hero's action should remain unchanged while scrolling,
24994 // but for the sake of scripts, here's an eye-watering kludge.
24995 1114672 actiontype lastaction = action;
24996 1114672 action=scrolling; FFCore.setHeroAction(scrolling);
24997
2/2
✓ Branch 0 taken 557221 times.
✓ Branch 1 taken 557451 times.
1114672 if(waitdraw)
24998 {
24999 557221 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
25000 557221 }
25001 else
25002 {
25003 557451 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
25004 }
25005 1114672 zfix storex = x, storey = y;
25006
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 280312 times.
✓ Branch 2 taken 184204 times.
✓ Branch 3 taken 292066 times.
✓ Branch 4 taken 358090 times.
1114672 switch(scrolldir)
25007 {
25008 case up:
25009
2/2
✓ Branch 0 taken 235176 times.
✓ Branch 1 taken 45136 times.
280312 if(y < 160) y = 176;
25010
4/4
✓ Branch 0 taken 38397 times.
✓ Branch 1 taken 6739 times.
✓ Branch 2 taken 14049 times.
✓ Branch 3 taken 24348 times.
45136 else if(cx > 0 && !end_frames) y = sy + 156;
25011 20788 else y = 160;
25012
25013 280312 break;
25014
25015 case down:
25016
2/2
✓ Branch 0 taken 153876 times.
✓ Branch 1 taken 30328 times.
184204 if(y > 0) y = -16;
25017
4/4
✓ Branch 0 taken 25547 times.
✓ Branch 1 taken 4781 times.
✓ Branch 2 taken 10339 times.
✓ Branch 3 taken 15208 times.
30328 else if(cx > 0 && !end_frames) y = sy - 172;
25018 15120 else y = 0;
25019
25020 184204 break;
25021
25022 case left:
25023
2/2
✓ Branch 0 taken 268540 times.
✓ Branch 1 taken 23526 times.
292066 if(x < 240) x = 256;
25024
2/2
✓ Branch 0 taken 19604 times.
✓ Branch 1 taken 3922 times.
23526 else if(cx > 0) x = sx + 236;
25025 3922 else x = 240;
25026
25027 292066 break;
25028
25029 case right:
25030
2/2
✓ Branch 0 taken 329314 times.
✓ Branch 1 taken 28776 times.
358090 if(x > 0) x = -16;
25031
2/2
✓ Branch 0 taken 24011 times.
✓ Branch 1 taken 4765 times.
28776 else if(cx > 0) x = sx - 252;
25032 4765 else x = 0;
25033
25034 358090 break;
25035 }
25036
2/2
✓ Branch 0 taken 557221 times.
✓ Branch 1 taken 557451 times.
1114672 if(waitdraw)
25037 {
25038
3/4
✓ Branch 0 taken 557221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 462286 times.
✓ Branch 3 taken 94935 times.
557221 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
25039 {
25040 94935 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
25041 94935 global_wait&= ~(1<<GLOBAL_SCRIPT_GAME);
25042 94935 }
25043 557221 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
25044
4/6
✓ Branch 0 taken 557221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3407 times.
✓ Branch 3 taken 553814 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3407 times.
557221 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25045 {
25046 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
25047 3407 player_waitdraw = false;
25048 3407 }
25049 557221 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
25050
4/6
✓ Branch 0 taken 557221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 557187 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 34 times.
557221 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25051 {
25052 34 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
25053 34 dmap_waitdraw = false;
25054 34 }
25055 557221 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
25056
2/6
✓ Branch 0 taken 557221 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 557221 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
557221 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25057 {
25058 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
25059 passive_subscreen_waitdraw = false;
25060 }
25061 557221 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
25062
4/10
✓ Branch 0 taken 557221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 557204 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 17 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
557221 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25063 {
25064 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
25065 tmpscr->screen_waitdraw = 0;
25066 }
25067 557221 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
25068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 557221 times.
557221 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
25069 {
25070 557221 FFCore.itemScriptEngineOnWaitdraw();
25071 557221 }
25072 557221 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
25073 557221 }
25074 else
25075 {
25076
4/8
✓ Branch 0 taken 557451 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 557433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
557451 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->preloadscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25077 {
25078 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
25079 }
25080 557451 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
25081
3/4
✓ Branch 0 taken 557451 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 409859 times.
✓ Branch 3 taken 147592 times.
557451 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (g_doscript & (1<<GLOBAL_SCRIPT_GAME)))
25082 {
25083 147592 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
25084 147592 }
25085 557451 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
25086
5/6
✓ Branch 0 taken 557451 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549064 times.
✓ Branch 3 taken 8387 times.
✓ Branch 4 taken 545657 times.
✓ Branch 5 taken 3407 times.
557451 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && player_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
25087 {
25088 3407 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
25089 3407 }
25090 557451 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
25091
4/6
✓ Branch 0 taken 557451 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 557451 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 545657 times.
✓ Branch 5 taken 11794 times.
557451 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25092 {
25093 11794 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
25094 11794 }
25095 557451 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
25096
4/6
✓ Branch 0 taken 557451 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 557451 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 545657 times.
✓ Branch 5 taken 11794 times.
557451 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_doscript && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25097 {
25098 11794 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
25099 11794 }
25100 557451 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
25101 557451 bool old = get_bit(quest_rules, qr_OLD_ITEMDATA_SCRIPT_TIMING);
25102
3/4
✓ Branch 0 taken 557451 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5612 times.
✓ Branch 3 taken 551839 times.
557451 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
25103 551839 FFCore.itemScriptEngine();
25104 557451 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
25105
3/4
✓ Branch 0 taken 557451 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551839 times.
✓ Branch 3 taken 5612 times.
557451 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
25106 5612 FFCore.itemScriptEngine();
25107 }
25108
25109 1114672 x = storex, y = storey;
25110
25111 1114672 action=lastaction; FFCore.setHeroAction(lastaction);
25112 1114672 }
25113
25114 //Has solving the maze enabled a side warp?
25115 //Only used just before scrolling screens
25116 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
25117 // return true to abort the topmost scrollscr() call. -L
25118 8247 bool HeroClass::maze_enabled_sizewarp(int32_t scrolldir)
25119 {
25120
2/2
✓ Branch 0 taken 24741 times.
✓ Branch 1 taken 8247 times.
32988 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
25121
25122
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 8104 times.
8247 lastdir[3] = tmpscr->flags&fMAZE ? scrolldir : 0xFF;
25123
25124
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8247 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8247 if(tmpscr->flags8&fMAZEvSIDEWARP && tmpscr->flags&fMAZE && scrolldir != tmpscr->exitdir)
25125 {
25126 switch(scrolldir)
25127 {
25128 case up:
25129 if(tmpscr->flags2&wfUP && checkmaze(tmpscr,true))
25130 {
25131 lastdir[3] = 0xFF;
25132 sdir=up;
25133 dowarp(1,(tmpscr->sidewarpindex)&3);
25134 return true;
25135 }
25136
25137 break;
25138
25139 case down:
25140 if(tmpscr->flags2&wfDOWN && checkmaze(tmpscr,true))
25141 {
25142 lastdir[3] = 0xFF;
25143 sdir=down;
25144 dowarp(1,(tmpscr->sidewarpindex>>2)&3);
25145 return true;
25146 }
25147
25148 break;
25149
25150 case left:
25151 if(tmpscr->flags2&wfLEFT && checkmaze(tmpscr,true))
25152 {
25153 lastdir[3] = 0xFF;
25154 sdir=left;
25155 dowarp(1,(tmpscr->sidewarpindex>>4)&3);
25156 return true;
25157 }
25158
25159 break;
25160
25161 case right:
25162 if(tmpscr->flags2&wfRIGHT && checkmaze(tmpscr,true))
25163 {
25164 lastdir[3] = 0xFF;
25165 sdir=right;
25166 dowarp(1,(tmpscr->sidewarpindex)&3);
25167 return true;
25168 }
25169
25170 break;
25171 }
25172 }
25173
25174 8247 return false;
25175 8247 }
25176
25177 8247 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
25178 {
25179 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
25180
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 7693 times.
8247 if(get_bit(quest_rules, qr_VERYFASTSCROLLING))
25181 554 return 16;
25182
25183
2/2
✓ Branch 0 taken 6664 times.
✓ Branch 1 taken 1029 times.
7693 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0)
25184 {
25185
2/2
✓ Branch 0 taken 3641 times.
✓ Branch 1 taken 3023 times.
6664 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25186 }
25187 else
25188 {
25189
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
25190 {
25191 482 return 8;
25192 }
25193 else
25194 {
25195
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 332 times.
547 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 2 : 4;
25196 }
25197 }
25198 8247 }
25199
25200 8247 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
25201 {
25202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8247 times.
8247 if(get_bit(quest_rules, qr_NOSCROLL))
25203 return 0;
25204
25205
4/4
✓ Branch 0 taken 7693 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 6664 times.
✓ Branch 3 taken 1029 times.
8247 if( (get_bit(quest_rules, qr_VERYFASTSCROLLING) != 0) ||
25206 7693 (get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) != 0) )
25207 {
25208 7218 return 1;
25209 }
25210 else
25211 {
25212
4/4
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 327 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 547 times.
1029 if(scrolldir == up || scrolldir == down)
25213 {
25214
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 234 times.
482 return (isdungeon() && !get_bit(quest_rules,qr_FASTDNGN)) ? 4 : 2;
25215 }
25216 else
25217 {
25218 547 return 1;
25219 }
25220 }
25221 8247 }
25222
25223 6161 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
25224 {
25225 6161 int32_t lampid = current_item_id(itype_lantern);
25226
1/2
✓ Branch 0 taken 6161 times.
✗ Branch 1 not taken.
6161 if(lampid < 0) return;
25227 static bool lamp_paid = false;
25228
2/4
✓ Branch 0 taken 6161 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6161 times.
✗ Branch 3 not taken.
6161 if(!(checkbunny(lampid) && checkmagiccost(lampid,lamp_paid)))
25229 {
25230 lamp_paid = false;
25231 return;
25232 }
25233 6161 lamp_paid = true;
25234 6161 paymagiccost(lampid,false,true);
25235 6161 int32_t hx1 = x.getInt() - x1 + 8;
25236 6161 int32_t hy1 = y.getInt() - y1 + 8;
25237 6161 int32_t hx2 = x.getInt() - x2 + 8;
25238 6161 int32_t hy2 = y.getInt() - y2 + 8;
25239
25240 6161 itemdata& lamp = itemsbuf[lampid];
25241
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5545 times.
✓ Branch 2 taken 616 times.
6161 switch(lamp.misc1) //Shape
25242 {
25243 case 0: //Circle
25244 5545 doDarkroomCircle(hx1, hy1, lamp.misc2, darkscr_bmp_curscr);
25245 5545 doDarkroomCircle(hx2, hy2, lamp.misc2, darkscr_bmp_scrollscr);
25246 5545 break;
25247 case 1: //Lamp Cone
25248 616 doDarkroomCone(hx1, hy1, lamp.misc2, dir, darkscr_bmp_curscr);
25249 616 doDarkroomCone(hx2, hy2, lamp.misc2, dir, darkscr_bmp_scrollscr);
25250 616 break;
25251 }
25252 6161 }
25253
25254 8247 void HeroClass::scrollscr(int32_t scrolldir, int32_t destscr, int32_t destdmap)
25255 {
25256
2/4
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8247 times.
8247 if(action==freeze||action==sideswimfreeze)
25257 {
25258 return;
25259 }
25260
25261 8247 bool overlay = false;
25262
25263
2/4
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8247 times.
8247 if(scrolldir >= 0 && scrolldir <= 3)
25264 {
25265 8247 overlay = get_bit(&tmpscr[(currscr < 128) ? 0 : 1].sidewarpoverlayflags, scrolldir) ? true : false;
25266 8247 }
25267
25268
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 7967 times.
8247 if(destdmap == -1)
25269 {
25270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7967 times.
7967 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[currdmap].map].tileWidth
25271
1/2
✓ Branch 0 taken 7967 times.
✗ Branch 1 not taken.
7967 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[currdmap].map].tileHeight)
25272 return;
25273 7967 }
25274 else
25275 {
25276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(ZCMaps[currmap].tileWidth != ZCMaps[DMaps[destdmap].map].tileWidth
25277
1/2
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
280 || ZCMaps[currmap].tileHeight != ZCMaps[DMaps[destdmap].map].tileHeight)
25278 return;
25279 }
25280
25281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8247 times.
8247 if(maze_enabled_sizewarp(scrolldir)) // dowarp() was called
25282 return;
25283
25284 8247 kill_enemy_sfx();
25285 8247 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25286 8247 screenscrolling = true;
25287 8247 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
25288
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2334 times.
✓ Branch 2 taken 1632 times.
✓ Branch 3 taken 1934 times.
✓ Branch 4 taken 2347 times.
8247 switch(scrolldir)
25289 {
25290 case up:
25291 2334 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25292 2334 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
25293 2334 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25294 2334 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25295 2334 break;
25296 case down:
25297 1632 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25298 1632 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
25299 1632 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25300 1632 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25301 1632 break;
25302 case left:
25303 1934 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
25304 1934 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25305 1934 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25306 1934 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25307 1934 break;
25308 case right:
25309 2347 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
25310 2347 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25311 2347 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25312 2347 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25313 2347 break;
25314 }
25315 8247 FFCore.init_combo_doscript();
25316 8247 tmpscr[1] = tmpscr[0];
25317
25318 8247 const int32_t _mapsSize = ZCMaps[currmap].tileWidth * ZCMaps[currmap].tileHeight;
25319
25320
2/2
✓ Branch 0 taken 49482 times.
✓ Branch 1 taken 8247 times.
57729 for(int32_t i = 0; i < 6; i++)
25321 {
25322 49482 tmpscr3[i] = tmpscr2[i];
25323 49482 }
25324
25325 8247 conveyclk = 2;
25326
25327 8247 mapscr *newscr = &tmpscr[0];
25328 8247 mapscr *oldscr = &tmpscr[1];
25329
25330 //scroll x, scroll y, old screen x, old screen y, new screen x, new screen y
25331 8247 int32_t sx = 0, sy = 0, tx = 0, ty = 0, tx2 = 0, ty2 = 0;
25332 8247 int32_t cx = 0;
25333 8247 int32_t step = get_scroll_step(scrolldir);
25334 8247 int32_t delay = get_scroll_delay(scrolldir);
25335 8247 bool end_frames = false;
25336
25337 8247 int32_t scx = get_bit(quest_rules,qr_FASTDNGN) ? 30 : 0;
25338
2/2
✓ Branch 0 taken 7693 times.
✓ Branch 1 taken 554 times.
8247 if(get_bit(quest_rules, qr_VERYFASTSCROLLING)) //just a minor adjustment.
25339 554 scx = 32; //for sideview very fast screolling.
25340
25341
25342 8247 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging; bool lasttapping = tapping;
25343 8247 actiontype lastaction = action;
25344 8247 ALLOFF(false, false);
25345 // for now, restore Hero's previous action
25346
2/2
✓ Branch 0 taken 8017 times.
✓ Branch 1 taken 230 times.
8247 if(!get_bit(quest_rules, qr_SCROLLING_KILLS_CHARGE))
25347 8247 attackclk = lastattackclk; spins = lastspins; charging = lastcharging; tapping = lasttapping;
25348 8247 action=lastaction; FFCore.setHeroAction(lastaction);
25349
25350 8247 lstep = (lstep + 6) % 12;
25351 8247 cx = scx;
25352 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
25353
3/4
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6234 times.
✓ Branch 3 taken 2013 times.
8247 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && (global_wait & (1<<GLOBAL_SCRIPT_GAME)))
25354 {
25355 2013 ZScriptVersion::RunScript(SCRIPT_GLOBAL, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
25356 2013 global_wait &= ~(1<<GLOBAL_SCRIPT_GAME);
25357 2013 }
25358 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
25359
4/6
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 8053 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 194 times.
8247 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && player_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25360 {
25361 194 ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_ACTIVE, SCRIPT_PLAYER_ACTIVE);
25362 194 player_waitdraw = false;
25363 194 }
25364 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
25365
4/6
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
8247 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && dmap_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25366 {
25367 2 ZScriptVersion::RunScript(SCRIPT_DMAP, DMaps[currdmap].script,currdmap);
25368 2 dmap_waitdraw = false;
25369 2 }
25370 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
25371
2/6
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8247 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8247 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && passive_subscreen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25372 {
25373 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script,currdmap);
25374 passive_subscreen_waitdraw = false;
25375 }
25376 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
25377
2/8
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8247 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8247 if ( (!( FFCore.system_suspend[susptSCREENSCRIPTS] )) && tmpscr->script != 0 && tmpscr->screen_waitdraw && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
25378 {
25379 ZScriptVersion::RunScript(SCRIPT_SCREEN, tmpscr->script, 0);
25380 tmpscr->screen_waitdraw = 0;
25381 }
25382 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
25383
25384 8247 word c = tmpscr->numFFC();
25385
2/2
✓ Branch 0 taken 257785 times.
✓ Branch 1 taken 8247 times.
266032 for ( word q = 0; q < c; ++q )
25386 {
25387 //Z_scripterrlog("tmpscr->ffcswaitdraw is: %d\n", tmpscr->ffcswaitdraw);
25388
1/2
✓ Branch 0 taken 257785 times.
✗ Branch 1 not taken.
257785 if ( tmpscr->ffcswaitdraw&(1<<q) )
25389 {
25390 //Z_scripterrlog("FFC (%d) called Waitdraw()\n", q);
25391 if(tmpscr->ffcs[q].script != 0)
25392 {
25393 ZScriptVersion::RunScript(SCRIPT_FFC, tmpscr->ffcs[q].script, q);
25394 tmpscr->ffcswaitdraw &= ~(1<<q);
25395 }
25396 }
25397 257785 }
25398 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
25399 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
25400 //Waitdraw for item scripts.
25401 8247 FFCore.itemScriptEngineOnWaitdraw();
25402 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
25403 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
25404
25405 //Sprite scripts on Waitdraw
25406 8247 FFCore.eweaponScriptEngineOnWaitdraw();
25407 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
25408 8247 FFCore.itemSpriteScriptEngineOnWaitdraw();
25409 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
25410
25411 //This is no longer a do-while, as the first iteration is now slightly different. -Em
25412 8247 draw_screen(tmpscr,true,true);
25413
25414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8247 times.
8247 if(cx == scx)
25415 8247 rehydratelake(false);
25416
25417 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25418 8247 advanceframe(true);
25419
25420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8247 times.
8247 if(Quit)
25421 {
25422 screenscrolling = false;
25423 return;
25424 }
25425
25426 8247 ++cx;
25427
2/2
✓ Branch 0 taken 107023 times.
✓ Branch 1 taken 8247 times.
115270 while(cx < 32)
25428 {
25429
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 106994 times.
107023 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
25430 {
25431 29 script_drawing_commands.Clear();
25432 29 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25433 29 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
25434 29 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25435 29 }
25436 106994 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25437 107023 draw_screen(tmpscr,true,true);
25438
25439
1/2
✓ Branch 0 taken 107023 times.
✗ Branch 1 not taken.
107023 if(cx == scx)
25440 rehydratelake(false);
25441
25442 107023 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
25443 107023 advanceframe(true);
25444
25445
1/2
✓ Branch 0 taken 107023 times.
✗ Branch 1 not taken.
107023 if(Quit)
25446 {
25447 screenscrolling = false;
25448 return;
25449 }
25450
25451 107023 ++cx;
25452 }
25453 8247 script_drawing_commands.Clear();
25454 8247 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
25455
25456
25457 //clear Hero's last hits
25458 //for ( int32_t q = 0; q < 4; q++ ) sethitHeroUID(q, 0);
25459
25460
3/4
✓ Branch 0 taken 4091 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✓ Branch 3 taken 3485 times.
8247 switch(DMaps[currdmap].type&dmfTYPE)
25461 {
25462 case dmDNGN:
25463
1/2
✓ Branch 0 taken 3485 times.
✗ Branch 1 not taken.
3485 if(!get_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING))
25464 {
25465 markBmap(scrolldir);
25466 }
25467 3485 break;
25468 case dmOVERW: case dmBSOVERW:
25469
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 4014 times.
4091 if(get_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING))
25470 4014 break;
25471 [[fallthrough]];
25472 case dmCAVE:
25473 748 markBmap(scrolldir);
25474 748 break;
25475 }
25476
25477
1/2
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
8247 if(fixed_door)
25478 {
25479 unsetmapflag(mSECRET);
25480 fixed_door = false;
25481 }
25482 //Z_scripterrlog("Setting 'scrolling_scr' from %d to %d\n", scrolling_scr, currscr);
25483 8247 scrolling_scr = currscr;
25484
25485
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2334 times.
✓ Branch 2 taken 1632 times.
✓ Branch 3 taken 1934 times.
✓ Branch 4 taken 2347 times.
8247 switch(scrolldir)
25486 {
25487 case up:
25488 {
25489
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 2290 times.
2334 if(destscr != -1)
25490 44 currscr = destscr;
25491
3/4
✓ Branch 0 taken 2249 times.
✓ Branch 1 taken 41 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2249 times.
2290 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25492 2249 currscr -= 16;
25493
25494 2334 loadscr(0,destdmap,currscr,scrolldir,overlay);
25495 2334 blit(scrollbuf,scrollbuf,0,0,0,176,256,176);
25496 2334 putscr(scrollbuf,0,0,newscr);
25497 2334 putscrdoors(scrollbuf,0,0,newscr);
25498 2334 sy=176;
25499
25500
2/2
✓ Branch 0 taken 2007 times.
✓ Branch 1 taken 327 times.
2334 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25501 327 sy+=3;
25502
25503 2334 cx=176/step;
25504 2334 FFCore.init_combo_doscript();
25505 }
25506 2334 break;
25507
25508 case down:
25509 {
25510
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1581 times.
1632 if(destscr != -1)
25511 51 currscr = destscr;
25512
3/4
✓ Branch 0 taken 1564 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1564 times.
1581 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25513 1564 currscr += 16;
25514
25515 1632 loadscr(0,destdmap,currscr,scrolldir,overlay);
25516 1632 putscr(scrollbuf,0,176,newscr);
25517 1632 putscrdoors(scrollbuf,0,176,newscr);
25518 1632 sy = 0;
25519
25520
2/2
✓ Branch 0 taken 1477 times.
✓ Branch 1 taken 155 times.
1632 if(get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING) == 0)
25521 155 sy+=3;
25522
25523 1632 cx = 176 / step;
25524 1632 FFCore.init_combo_doscript();
25525 }
25526 1632 break;
25527
25528 case left:
25529 {
25530
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 1868 times.
1934 if(destscr!=-1)
25531 66 currscr = destscr;
25532
3/4
✓ Branch 0 taken 1850 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1850 times.
1868 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25533 1850 --currscr;
25534
25535 1934 loadscr(0,destdmap,currscr,scrolldir,overlay);
25536 1934 blit(scrollbuf,scrollbuf,0,0,256,0,256,176);
25537 1934 putscr(scrollbuf,0,0,newscr);
25538 1934 putscrdoors(scrollbuf,0,0,newscr);
25539 1934 sx = 256;
25540 1934 cx = 256 / step;
25541 1934 FFCore.init_combo_doscript();
25542 }
25543 1934 break;
25544
25545 case right:
25546 {
25547
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 2228 times.
2347 if(destscr != -1)
25548 119 currscr = destscr;
25549
3/4
✓ Branch 0 taken 2201 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2201 times.
2228 else if(checkmaze(oldscr,true) && !edge_of_dmap(scrolldir))
25550 2201 ++currscr;
25551
25552 2347 loadscr(0,destdmap,currscr,scrolldir,overlay);
25553 2347 putscr(scrollbuf,256,0,newscr);
25554 2347 putscrdoors(scrollbuf,256,0,tmpscr);
25555 2347 sx = 0;
25556 2347 cx = 256 / step;
25557 2347 FFCore.init_combo_doscript();
25558 }
25559 2347 break;
25560 }
25561
25562 // change Hero's state if entering water
25563 8247 int32_t ahead = lookahead(scrolldir);
25564 8247 int32_t aheadflag = lookaheadflag(scrolldir);
25565 8247 int32_t lookaheadx = vbound(x+8,0,240); //var = vbound(val, n1, n2), not bound(var, n1, n2) -Z
25566 8247 int32_t lookaheady = vbound(y + (bigHitbox?8:12),0,160);
25567 8247 int32_t wateraheadx1 = vbound(x+4,0,240);
25568 8247 int32_t wateraheadx2 = vbound(x+11,0,240);;
25569 8247 int32_t wateraheady1 = vbound(y+9,0,160);
25570 8247 int32_t wateraheady2 = vbound(y+15,0,160);
25571 //bound(cx, 0, 240); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25572 //bound(cy, 0, 168); //Fix crash during screen scroll when Hero is moving too quickly through a corner - DarkDragon
25573 //y+8 could be 168 //Attempt to fix a frash where scrolling through the lower-left corner could crassh ZC as reported by Lut. -Z
25574
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2334 times.
✓ Branch 2 taken 1632 times.
✓ Branch 3 taken 1934 times.
✓ Branch 4 taken 2347 times.
8247 switch(scrolldir)
25575 {
25576 case up:
25577 2334 lookaheady=160;
25578 2334 wateraheady1=160;
25579 2334 wateraheady2=160;
25580 2334 break;
25581
25582 case down:
25583 1632 lookaheady=0;
25584 1632 wateraheady1=0;
25585 1632 wateraheady2=0;
25586 1632 break;
25587
25588 case left:
25589 1934 lookaheadx=240;
25590 1934 wateraheadx1=240;
25591 1934 wateraheadx2=240;
25592 1934 break;
25593
25594 case right:
25595 2347 lookaheadx=0;
25596 2347 wateraheadx1=0;
25597 2347 wateraheadx2=0;
25598 2347 break;
25599 }
25600
25601 8247 bool nowinwater = false;
25602
25603
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 8209 times.
8247 if(lastaction != inwind)
25604 {
25605
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 8019 times.
8209 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
25606 {
25607
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 183 times.
190 if (lookaheadraftflag(scrolldir))
25608 {
25609 183 action=rafting; FFCore.setHeroAction(rafting);
25610 183 raftclk=0;
25611 183 }
25612 190 }
25613
5/6
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 7861 times.
✓ Branch 2 taken 158 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✓ Branch 5 taken 137 times.
8019 else if(iswaterex(ahead, currmap, currscr, -1, wateraheadx1,wateraheady1) && iswaterex(ahead, currmap, currscr, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
25614 {
25615
9/16
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 134 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
137 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
25616 {
25617 134 SetSwim();
25618 134 hopclk = 0xFF;
25619 134 nowinwater = true;
25620 134 }
25621 else
25622 {
25623 3 action=hopping; FFCore.setHeroAction(hopping);
25624 3 hopclk = 2;
25625 3 nowinwater = true;
25626 }
25627 137 }
25628
3/4
✓ Branch 0 taken 7869 times.
✓ Branch 1 taken 13 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7882 times.
7882 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
25629 {
25630 action = lastaction; FFCore.setHeroAction(lastaction);
25631 }
25632 else
25633 {
25634 7882 action=none; FFCore.setHeroAction(none);
25635 }
25636 8209 }
25637
25638 // The naturaldark state can be read/set by an FFC script before
25639 // fade() or lighting() is called.
25640 8247 naturaldark = ((TheMaps[currmap*MAPSCRS+currscr].flags & fDARK) != 0);
25641
25642
2/2
✓ Branch 0 taken 8053 times.
✓ Branch 1 taken 194 times.
8247 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
25643
25644
2/2
✓ Branch 0 taken 8057 times.
✓ Branch 1 taken 190 times.
8247 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
25645 //Preloaded ffc scripts
25646 8247 homescr=currscr;
25647 8247 auto olddmap = currdmap;
25648
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 7967 times.
8247 auto newdmap = (destdmap >= 0) ? destdmap : currdmap;
25649
25650 8247 currdmap = newdmap;
25651 8247 ffscript_engine(true);
25652 8247 currdmap = olddmap;
25653
25654 // There are two occasions when scrolling must be darkened:
25655 // 1) When scrolling into a dark room.
25656 // 2) When scrolling between DMaps of different colours.
25657
4/4
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 7967 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 125 times.
8247 if(destdmap != -1 && DMaps[destdmap].color != currcset)
25658 {
25659
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
25660 125 darkroom = true;
25661 125 }
25662
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 7956 times.
8122 else if(!darkroom)
25663 7956 lighting(false, false); // NES behaviour: fade to dark before scrolling
25664
25665
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 8057 times.
8247 if(action != rafting) // Is this supposed to be here?!
25666
25667 8057 cx++; //This was the easiest way to re-arrange the loop so drawing is in the middle
25668
25669 8247 cx *= delay; //so we can have drawing re-done every frame,
25670 //previously it was for(0 to delay) advanceframes at end of loop
25671 8247 int32_t no_move = 0;
25672
25673 8247 currdmap = newdmap;
25674
4/4
✓ Branch 0 taken 8247 times.
✓ Branch 1 taken 557192 times.
✓ Branch 2 taken 557192 times.
✓ Branch 3 taken 8247 times.
565439 for(word i = 0; cx >= 0 && delay != 0; i++, cx--) //Go!
25675 {
25676
3/4
✓ Branch 0 taken 557192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 435743 times.
✓ Branch 3 taken 121449 times.
557192 if (replay_is_active() && replay_get_version() < 3)
25677 {
25678 121449 replay_poll();
25679 121449 }
25680
1/2
✓ Branch 0 taken 557192 times.
✗ Branch 1 not taken.
557192 if(Quit)
25681 {
25682 screenscrolling = false;
25683 return;
25684 }
25685
25686
25687 557192 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false);
25688
25689
2/2
✓ Branch 0 taken 510761 times.
✓ Branch 1 taken 46431 times.
557192 if(no_move > 0)
25690 46431 no_move--;
25691
25692 //Don't want to move things on the first or last iteration, or between delays
25693
6/6
✓ Branch 0 taken 548945 times.
✓ Branch 1 taken 8247 times.
✓ Branch 2 taken 537214 times.
✓ Branch 3 taken 11731 times.
✓ Branch 4 taken 23129 times.
✓ Branch 5 taken 514085 times.
557192 if(i == 0 || cx == 0 || cx % delay != 0)
25694 43107 no_move++;
25695
25696
4/4
✓ Branch 0 taken 417070 times.
✓ Branch 1 taken 140122 times.
✓ Branch 2 taken 92079 times.
✓ Branch 3 taken 324991 times.
557192 if(scrolldir == up || scrolldir == down)
25697 {
25698
2/2
✓ Branch 0 taken 197024 times.
✓ Branch 1 taken 35177 times.
232201 if(!get_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING))
25699 {
25700 //Add a few extra frames if on the second loop and cool scrolling is not set
25701
2/2
✓ Branch 0 taken 34695 times.
✓ Branch 1 taken 482 times.
35177 if(i == 1)
25702 {
25703 482 cx += (scrolldir == down) ? 3 : 2;
25704 482 no_move += (scrolldir == down) ? 3 : 2;
25705 482 }
25706 35177 }
25707 else
25708 {
25709 //4 frames after we've finished scrolling of being still
25710
4/4
✓ Branch 0 taken 6968 times.
✓ Branch 1 taken 190056 times.
✓ Branch 2 taken 3484 times.
✓ Branch 3 taken 3484 times.
197024 if(cx == 0 && !end_frames)
25711 {
25712 3484 cx += 4;
25713 3484 no_move += 4;
25714 3484 end_frames = true;
25715 3484 }
25716 }
25717 232201 }
25718
25719 //Move Hero and the scroll position
25720
2/2
✓ Branch 0 taken 54678 times.
✓ Branch 1 taken 502514 times.
557192 if(!no_move)
25721 {
25722
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 110646 times.
✓ Branch 2 taken 75439 times.
✓ Branch 3 taken 142132 times.
✓ Branch 4 taken 174297 times.
502514 switch(scrolldir)
25723 {
25724 case up:
25725 110646 sy -= step;
25726 110646 y += step;
25727 110646 break;
25728
25729 case down:
25730 75439 sy += step;
25731 75439 y -= step;
25732 75439 break;
25733
25734 case left:
25735 142132 sx -= step;
25736 142132 x += step;
25737 142132 break;
25738
25739 case right:
25740 174297 sx += step;
25741 174297 x -= step;
25742 174297 break;
25743 }
25744
25745 //bound Hero when me move him off the screen in the last couple of frames of scrolling
25746
2/2
✓ Branch 0 taken 9716 times.
✓ Branch 1 taken 492798 times.
502514 if(y > 160) y = 160;
25747
25748
2/2
✓ Branch 0 taken 6539 times.
✓ Branch 1 taken 495975 times.
502514 if(y < 0) y = 0;
25749
25750
2/2
✓ Branch 0 taken 8842 times.
✓ Branch 1 taken 493672 times.
502514 if(x > 240) x = 240;
25751
25752
2/2
✓ Branch 0 taken 10842 times.
✓ Branch 1 taken 491672 times.
502514 if(x < 0) x = 0;
25753
25754
4/4
✓ Branch 0 taken 502268 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 502258 times.
502514 if(ladderx > 0 || laddery > 0)
25755 {
25756 // If the ladder moves on both axes, the player can
25757 // gradually shift it by going back and forth
25758
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
256 if(scrolldir==up || scrolldir==down)
25759 laddery = y.getInt();
25760 else
25761 256 ladderx = x.getInt();
25762 256 }
25763 502514 }
25764
25765 //Drawing
25766 557192 tx = sx;
25767 557192 ty = sy;
25768 557192 tx2 = sx;
25769 557192 ty2 = sy;
25770
25771
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 178991 times.
✓ Branch 2 taken 92079 times.
✓ Branch 3 taken 146000 times.
✓ Branch 4 taken 140122 times.
557192 switch(scrolldir)
25772 {
25773 case right:
25774 178991 FFCore.ScrollingData[SCROLLDATA_NX] = 256-tx2;
25775 178991 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25776 178991 FFCore.ScrollingData[SCROLLDATA_OX] = -tx2;
25777 178991 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25778 178991 tx -= 256;
25779 178991 break;
25780
25781 case down:
25782 92079 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25783 92079 FFCore.ScrollingData[SCROLLDATA_NY] = 176-ty2;
25784 92079 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25785 92079 FFCore.ScrollingData[SCROLLDATA_OY] = -ty2;
25786 92079 ty -= 176;
25787 92079 break;
25788
25789 case left:
25790 146000 FFCore.ScrollingData[SCROLLDATA_NX] = -tx2;
25791 146000 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
25792 146000 FFCore.ScrollingData[SCROLLDATA_OX] = 256-tx2;
25793 146000 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
25794 146000 tx2 -= 256;
25795 146000 break;
25796
25797 case up:
25798 140122 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
25799 140122 FFCore.ScrollingData[SCROLLDATA_NY] = -ty2;
25800 140122 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
25801 140122 FFCore.ScrollingData[SCROLLDATA_OY] = 176-ty2;
25802 140122 ty2 -= 176;
25803 140122 break;
25804 }
25805
25806 //FFScript.OnWaitdraw()
25807 557192 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, true); //Waitdraw
25808
25809 557192 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
25810 557192 clear_bitmap(scrollbuf);
25811 557192 clear_bitmap(framebuf);
25812 557192 clear_a5_bmp(rti_infolayer.bitmap);
25813
25814
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 140122 times.
✓ Branch 2 taken 92079 times.
✓ Branch 3 taken 146000 times.
✓ Branch 4 taken 178991 times.
557192 switch(scrolldir)
25815 {
25816 case up:
25817
1/2
✓ Branch 0 taken 140122 times.
✗ Branch 1 not taken.
140122 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25818
25819
1/2
✓ Branch 0 taken 140122 times.
✗ Branch 1 not taken.
140122 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, -176+playing_field_offset, 3);
25820
25821
1/2
✓ Branch 0 taken 140122 times.
✗ Branch 1 not taken.
140122 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25822
25823
1/2
✓ Branch 0 taken 140122 times.
✗ Branch 1 not taken.
140122 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, -176+playing_field_offset, 3);
25824
25825 // Draw both screens' background layer primitives together, after both layers' combos.
25826 // Not ideal, but probably good enough for all realistic purposes.
25827
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140122 times.
✓ Branch 2 taken 140122 times.
✗ Branch 3 not taken.
140122 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25828
25829
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140122 times.
✓ Branch 2 taken 140122 times.
✗ Branch 3 not taken.
140122 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25830
25831 140122 putscr(scrollbuf, 0, 0, newscr);
25832 140122 putscr(scrollbuf, 0, 176, oldscr);
25833 140122 break;
25834
25835 case down:
25836
1/2
✓ Branch 0 taken 92079 times.
✗ Branch 1 not taken.
92079 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, -176+playing_field_offset, 2);
25837
25838
1/2
✓ Branch 0 taken 92079 times.
✗ Branch 1 not taken.
92079 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25839
25840
1/2
✓ Branch 0 taken 92079 times.
✗ Branch 1 not taken.
92079 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, -176+playing_field_offset, 2);
25841
25842
1/2
✓ Branch 0 taken 92079 times.
✗ Branch 1 not taken.
92079 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25843
25844
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 92079 times.
✓ Branch 2 taken 92079 times.
✗ Branch 3 not taken.
92079 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25845
25846
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 92079 times.
✓ Branch 2 taken 92079 times.
✗ Branch 3 not taken.
92079 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25847
25848 92079 putscr(scrollbuf, 0, 0, oldscr);
25849 92079 putscr(scrollbuf, 0, 176, newscr);
25850 92079 break;
25851
25852 case left:
25853
2/2
✓ Branch 0 taken 145934 times.
✓ Branch 1 taken 66 times.
146000 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, 0, playing_field_offset, 2);
25854
25855
1/2
✓ Branch 0 taken 146000 times.
✗ Branch 1 not taken.
146000 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, -256, playing_field_offset, 3);
25856
25857
1/2
✓ Branch 0 taken 146000 times.
✗ Branch 1 not taken.
146000 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, 0, playing_field_offset, 2);
25858
25859
1/2
✓ Branch 0 taken 146000 times.
✗ Branch 1 not taken.
146000 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, -256, playing_field_offset, 3);
25860
25861
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 145934 times.
✓ Branch 2 taken 145934 times.
✓ Branch 3 taken 66 times.
146000 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25862
25863
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 146000 times.
✓ Branch 2 taken 146000 times.
✗ Branch 3 not taken.
146000 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25864
25865 146000 putscr(scrollbuf, 0, 0, newscr);
25866 146000 putscr(scrollbuf, 256, 0, oldscr);
25867 146000 break;
25868
25869 case right:
25870
2/2
✓ Branch 0 taken 178925 times.
✓ Branch 1 taken 66 times.
178991 if(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, newscr, -256, playing_field_offset, 2);
25871
25872
2/2
✓ Branch 0 taken 178925 times.
✓ Branch 1 taken 66 times.
178991 if(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, oldscr, 0, playing_field_offset, 3);
25873
25874
1/2
✓ Branch 0 taken 178991 times.
✗ Branch 1 not taken.
178991 if(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, newscr, -256, playing_field_offset, 2);
25875
25876
1/2
✓ Branch 0 taken 178991 times.
✗ Branch 1 not taken.
178991 if(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, oldscr, 0, playing_field_offset, 3);
25877
25878
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 178925 times.
✓ Branch 2 taken 178859 times.
✓ Branch 3 taken 132 times.
178991 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[currdmap].flags&dmfLAYER2BG)) do_primitives(scrollbuf, 2, newscr, sx, sy);
25879
25880
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 178991 times.
✓ Branch 2 taken 178991 times.
✗ Branch 3 not taken.
178991 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[currdmap].flags&dmfLAYER3BG)) do_primitives(scrollbuf, 3, newscr, sx, sy);
25881
25882 178991 putscr(scrollbuf, 0, 0, oldscr);
25883 178991 putscr(scrollbuf, 256, 0, newscr);
25884 178991 break;
25885 }
25886
25887 557192 blit(scrollbuf, framebuf, sx, sy, 0, playing_field_offset, 256, 168);
25888 557192 do_primitives(framebuf, 0, newscr, 0, playing_field_offset);
25889
25890 557192 do_layer(framebuf, 0, 1, oldscr, tx2, ty2, 3);
25891 557192 do_layer(framebuf, 0, 1, newscr, tx, ty, 2, false, true);
25892
25893
2/2
✓ Branch 0 taken 508833 times.
✓ Branch 1 taken 48359 times.
557192 if(get_bit(quest_rules, qr_FFCSCROLL))
25894 {
25895 48359 do_layer(framebuf, -3, 0, oldscr, tx2, ty2, 3, true); //ffcs
25896 48359 do_layer(framebuf, -3, 0, newscr, tx, ty, 2, true);
25897 48359 }
25898
25899
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 557126 times.
557192 if(!(XOR(oldscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) ) do_layer(framebuf, 0, 2, oldscr, tx2, ty2, 3);
25900
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 557060 times.
557192 if(!(XOR(newscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, newscr, tx, ty, 2, false, !(oldscr->flags7&fLAYER2BG));
25901
25902 //push blocks
25903 557192 do_layer(framebuf, -2, 0, oldscr, tx2, ty2, 3);
25904 557192 do_layer(framebuf, -2, 0, newscr, tx, ty, 2);
25905
2/2
✓ Branch 0 taken 549064 times.
✓ Branch 1 taken 8128 times.
557192 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
25906 {
25907 8128 do_layer(framebuf, -2, 1, oldscr, tx2, ty2, 3);
25908 8128 do_layer(framebuf, -2, 1, newscr, tx, ty, 2);
25909 8128 do_layer(framebuf, -2, 2, oldscr, tx2, ty2, 3);
25910 8128 do_layer(framebuf, -2, 2, newscr, tx, ty, 2);
25911 8128 }
25912
25913 557192 do_walkflags(oldscr, tx2, ty2,3); //show walkflags if the cheat is on
25914 557192 do_walkflags(newscr, tx, ty,2);
25915
25916 557192 do_effectflags(oldscr, tx2, ty2,3); //show effectflags if the cheat is on
25917 557192 do_effectflags(newscr, tx, ty,2);
25918
25919
25920 557192 putscrdoors(framebuf, 0-tx2, 0-ty2+playing_field_offset, oldscr);
25921 557192 putscrdoors(framebuf, 0-tx, 0-ty+playing_field_offset, newscr);
25922 557192 herostep();
25923
25924
5/6
✓ Branch 0 taken 557142 times.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 557092 times.
✓ Branch 4 taken 557142 times.
✓ Branch 5 taken 557142 times.
557192 if((z > 0 || fakez > 0) && (!get_bit(quest_rules,qr_SHADOWSFLICKER) || frame&1))
25925 {
25926 1114234 drawshadow(framebuf, get_bit(quest_rules, qr_TRANSSHADOWS) != 0);
25927 1114234 }
25928
25929
4/4
✓ Branch 0 taken 300953 times.
✓ Branch 1 taken 256239 times.
✓ Branch 2 taken 124985 times.
✓ Branch 3 taken 175968 times.
557192 if(!isdungeon() || get_bit(quest_rules,qr_FREEFORM))
25930 {
25931 381224 draw_under(framebuf); //draw the ladder or raft
25932 381224 decorations.draw2(framebuf, true);
25933 381224 draw(framebuf); //Hero
25934 381224 decorations.draw(framebuf, true);
25935 381224 }
25936
25937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 557192 times.
557192 if(!(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, oldscr, tx2, ty2, 3);
25938
25939 557192 do_layer(framebuf, 0, 4, oldscr, tx2, ty2, 3); //layer 4
25940 557192 do_layer(framebuf, -1, 0, oldscr, tx2, ty2, 3); //overhead combos
25941
2/2
✓ Branch 0 taken 551951 times.
✓ Branch 1 taken 5241 times.
557192 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25942 {
25943 5241 do_layer(framebuf, -1, 1, oldscr, tx2, ty2, 3); //overhead combos
25944 5241 do_layer(framebuf, -1, 2, oldscr, tx2, ty2, 3); //overhead combos
25945 5241 }
25946 557192 do_layer(framebuf, 0, 5, oldscr, tx2, ty2, 3); //layer 5
25947 557192 do_layer(framebuf, -4, 0, oldscr, tx2, ty2, 3, true); //overhead FFCs
25948 557192 do_layer(framebuf, 0, 6, oldscr, tx2, ty2, 3); //layer 6
25949
25950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 557192 times.
557192 if(!(XOR(newscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, newscr, tx, ty, 2, false, !(XOR(oldscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)));
25951
25952 557192 do_layer(framebuf, 0, 4, newscr, tx, ty, 2, false, true); //layer 4
25953 557192 do_layer(framebuf, -1, 0, newscr, tx, ty, 2); //overhead combos
25954
2/2
✓ Branch 0 taken 551951 times.
✓ Branch 1 taken 5241 times.
557192 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
25955 {
25956 5241 do_layer(framebuf, -1, 1, newscr, tx, ty, 2); //overhead combos
25957 5241 do_layer(framebuf, -1, 2, newscr, tx, ty, 2); //overhead combos
25958 5241 }
25959 557192 do_layer(framebuf, 0, 5, newscr, tx, ty, 2, false, true); //layer 5
25960 557192 do_layer(framebuf, -4, 0, newscr, tx, ty, 2, true); //overhead FFCs
25961 557192 do_layer(framebuf, 0, 6, newscr, tx, ty, 2, false, true); //layer 6
25962
25963
25964
1/2
✓ Branch 0 taken 557192 times.
✗ Branch 1 not taken.
557192 if(msg_bg_display_buf->clip == 0)
25965 {
25966 blit_msgstr_bg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25967 }
25968
1/2
✓ Branch 0 taken 557192 times.
✗ Branch 1 not taken.
557192 if(msg_portrait_display_buf->clip == 0)
25969 {
25970 blit_msgstr_prt(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25971 }
25972
1/2
✓ Branch 0 taken 557192 times.
✗ Branch 1 not taken.
557192 if(msg_txt_display_buf->clip == 0)
25973 {
25974 blit_msgstr_fg(framebuf, tx2, ty2, 0, playing_field_offset, 256, 168);
25975 }
25976
25977
6/6
✓ Branch 0 taken 11535 times.
✓ Branch 1 taken 545657 times.
✓ Branch 2 taken 11309 times.
✓ Branch 3 taken 226 times.
✓ Branch 4 taken 83 times.
✓ Branch 5 taken 11226 times.
557192 if(get_bit(quest_rules, qr_NEW_DARKROOM) && ((newscr->flags&fDARK)||(oldscr->flags&fDARK)))
25978 {
25979 309 clear_to_color(darkscr_bmp_curscr, game->get_darkscr_color());
25980 309 clear_to_color(darkscr_bmp_curscr_trans, game->get_darkscr_color());
25981 309 clear_to_color(darkscr_bmp_scrollscr, game->get_darkscr_color());
25982 309 clear_to_color(darkscr_bmp_scrollscr_trans, game->get_darkscr_color());
25983 309 calc_darkroom_combos(true);
25984 309 calc_darkroom_hero(FFCore.ScrollingData[SCROLLDATA_NX], FFCore.ScrollingData[SCROLLDATA_NY],FFCore.ScrollingData[SCROLLDATA_OX], FFCore.ScrollingData[SCROLLDATA_OY]);
25985 309 }
25986
25987
4/4
✓ Branch 0 taken 11535 times.
✓ Branch 1 taken 545657 times.
✓ Branch 2 taken 8016 times.
✓ Branch 3 taken 3519 times.
557192 if(get_bit(quest_rules, qr_NEW_DARKROOM) && get_bit(quest_rules, qr_NEWDARK_L6))
25988 {
25989 3519 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
25990 3519 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
25991 3519 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
25992
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(newscr->flags & fDARK)
25993 {
25994 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
25995 {
25996 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
25997 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
25998 }
25999
26000 color_map = &trans_table2;
26001 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
26002 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
26003 else
26004 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
26005 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
26006 color_map = &trans_table;
26007 }
26008
1/2
✓ Branch 0 taken 3519 times.
✗ Branch 1 not taken.
3519 if(oldscr->flags & fDARK)
26009 {
26010 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
26011 {
26012 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
26013 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
26014 }
26015
26016 color_map = &trans_table2;
26017 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
26018 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
26019 else
26020 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
26021 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
26022 color_map = &trans_table;
26023 }
26024 3519 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
26025 3519 }
26026 557192 put_passive_subscr(framebuf, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
26027
2/2
✓ Branch 0 taken 380982 times.
✓ Branch 1 taken 176210 times.
557192 if(get_bit(quest_rules,qr_SUBSCREENOVERSPRITES))
26028 176210 do_primitives(framebuf, 7, newscr, 0, playing_field_offset);
26029
26030
4/4
✓ Branch 0 taken 11535 times.
✓ Branch 1 taken 545657 times.
✓ Branch 2 taken 8016 times.
✓ Branch 3 taken 3519 times.
557192 if(get_bit(quest_rules, qr_NEW_DARKROOM) && !get_bit(quest_rules, qr_NEWDARK_L6))
26031 {
26032 8016 set_clip_rect(framebuf, 0, playing_field_offset, 256, 168+playing_field_offset);
26033 8016 int32_t dx1 = FFCore.ScrollingData[SCROLLDATA_NX], dy1 = FFCore.ScrollingData[SCROLLDATA_NY]+playing_field_offset;
26034 8016 int32_t dx2 = FFCore.ScrollingData[SCROLLDATA_OX], dy2 = FFCore.ScrollingData[SCROLLDATA_OY]+playing_field_offset;
26035
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 226 times.
8016 if(newscr->flags & fDARK)
26036 {
26037
1/2
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
226 if(newscr->flags9 & fDARK_DITHER) //dither the entire bitmap
26038 {
26039 ditherblit(darkscr_bmp_curscr,darkscr_bmp_curscr,0,game->get_dither_type(),game->get_dither_arg());
26040 ditherblit(darkscr_bmp_curscr_trans,darkscr_bmp_curscr_trans,0,game->get_dither_type(),game->get_dither_arg());
26041 }
26042
26043 226 color_map = &trans_table2;
26044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if(newscr->flags9 & fDARK_TRANS) //draw the dark as transparent
26045 draw_trans_sprite(framebuf, darkscr_bmp_curscr, dx1, dy1);
26046 else
26047 226 masked_blit(darkscr_bmp_curscr, framebuf, 0, 0, dx1, dy1, 256, 176);
26048 226 draw_trans_sprite(framebuf, darkscr_bmp_curscr_trans, dx1, dy1);
26049 226 color_map = &trans_table;
26050 226 }
26051
2/2
✓ Branch 0 taken 7807 times.
✓ Branch 1 taken 209 times.
8016 if(oldscr->flags & fDARK)
26052 {
26053
1/2
✓ Branch 0 taken 209 times.
✗ Branch 1 not taken.
209 if(oldscr->flags9 & fDARK_DITHER) //dither the entire bitmap
26054 {
26055 ditherblit(darkscr_bmp_scrollscr,darkscr_bmp_scrollscr,0,game->get_dither_type(),game->get_dither_arg());
26056 ditherblit(darkscr_bmp_scrollscr_trans,darkscr_bmp_scrollscr_trans,0,game->get_dither_type(),game->get_dither_arg());
26057 }
26058
26059 209 color_map = &trans_table2;
26060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 209 times.
209 if(oldscr->flags9 & fDARK_TRANS) //draw the dark as transparent
26061 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr, dx2, dy2);
26062 else
26063 209 masked_blit(darkscr_bmp_scrollscr, framebuf, 0, 0, dx2, dy2, 256, 176);
26064 209 draw_trans_sprite(framebuf, darkscr_bmp_scrollscr_trans, dx2, dy2);
26065 209 color_map = &trans_table;
26066 209 }
26067 8016 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
26068 8016 }
26069 557192 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
26070
26071 //end drawing
26072 557192 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
26073 557192 advanceframe(true/*,true,false*/);
26074
26075 //Don't clear the last frame, unless 'fixed'
26076
4/4
✓ Branch 0 taken 8247 times.
✓ Branch 1 taken 548945 times.
✓ Branch 2 taken 230 times.
✓ Branch 3 taken 8017 times.
557192 if(cx > 0 || get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
26077 549175 script_drawing_commands.Clear();
26078 557192 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
26079 557192 actiontype lastaction = action;
26080 557192 action=scrolling; FFCore.setHeroAction(scrolling);
26081 557192 FFCore.runF6Engine();
26082 557192 action=lastaction; FFCore.setHeroAction(lastaction);
26083 557192 } //end main scrolling loop
26084 8247 currdmap = olddmap;
26085
26086 8247 clear_bitmap(msg_txt_display_buf);
26087 8247 set_clip_state(msg_txt_display_buf, 1);
26088 8247 clear_bitmap(msg_bg_display_buf);
26089 8247 set_clip_state(msg_bg_display_buf, 1);
26090 8247 clear_bitmap(msg_portrait_display_buf);
26091 8247 set_clip_state(msg_portrait_display_buf, 1);
26092
26093 //Move hero to the other side of the screen if scrolling's not turned on
26094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8247 times.
8247 if(get_bit(quest_rules, qr_NOSCROLL))
26095 {
26096 switch(scrolldir)
26097 {
26098 case up:
26099 y = 160;
26100 break;
26101
26102 case down:
26103 y = 0;
26104 break;
26105
26106 case left:
26107 x = 240;
26108 break;
26109
26110 case right:
26111 x = 0;
26112 break;
26113 }
26114 }
26115
26116
3/4
✓ Branch 0 taken 8246 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 8247 times.
✗ Branch 3 not taken.
8247 if((z > 0 || fakez > 0) && isSideViewHero())
26117 {
26118 y -= z;
26119 y -= fakez;
26120 z = 0;
26121 fakez = 0;
26122 }
26123
26124 8247 set_respawn_point(false);
26125 8247 trySideviewLadder();
26126 8247 warpx = -1;
26127 8247 warpy = -1;
26128
26129 8247 screenscrolling = false;
26130 8247 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
26131 8247 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
26132 8247 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
26133 8247 FFCore.ScrollingData[SCROLLDATA_OX] = 0;
26134 8247 FFCore.ScrollingData[SCROLLDATA_OY] = 0;
26135
26136
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 7967 times.
8247 if(destdmap != -1)
26137 {
26138 280 bool changedlevel = false;
26139 280 bool changeddmap = false;
26140
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 207 times.
280 if(olddmap != destdmap)
26141 {
26142 207 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26143 207 changeddmap = true;
26144 207 }
26145
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 77 times.
280 if(DMaps[olddmap].level != DMaps[destdmap].level)
26146 {
26147 77 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26148 77 changedlevel = true;
26149 77 }
26150 280 dlevel = DMaps[destdmap].level;
26151 280 currdmap = destdmap;
26152
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 207 times.
280 if(changeddmap)
26153 {
26154 207 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26155 207 }
26156
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 77 times.
280 if(changedlevel)
26157 {
26158 77 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26159 77 }
26160 280 }
26161
26162 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
26163 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
26164 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
26165 //direction. -DD
26166
26167
2/2
✓ Branch 0 taken 8110 times.
✓ Branch 1 taken 137 times.
8247 if(nowinwater)
26168 {
26169 137 SetSwim();
26170 137 hopclk = 0xFF;
26171 137 }
26172
26173 // NES behaviour: Fade to light after scrolling
26174 8247 lighting(false, false); // No, we don't need to set naturaldark...
26175
26176 8247 init_dmap();
26177 8247 putscr(scrollbuf,0,0,newscr);
26178 8247 putscrdoors(scrollbuf,0,0,newscr);
26179
26180 // Check for raft flags
26181
6/6
✓ Branch 0 taken 8057 times.
✓ Branch 1 taken 190 times.
✓ Branch 2 taken 7920 times.
✓ Branch 3 taken 137 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 7869 times.
8247 if(action!=rafting && hopclk==0 && !toogam)
26182 {
26183
3/4
✓ Branch 0 taken 7866 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7866 times.
7869 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
26184 {
26185 3 sfx(tmpscr->secretsfx);
26186 3 action=rafting; FFCore.setHeroAction(rafting);
26187 3 raftclk=0;
26188 3 }
26189
26190 // Half a tile off?
26191
6/8
✓ Branch 0 taken 5889 times.
✓ Branch 1 taken 1977 times.
✓ Branch 2 taken 2341 times.
✓ Branch 3 taken 3548 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4318 times.
✓ Branch 6 taken 7866 times.
✗ Branch 7 not taken.
12184 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
26192 {
26193 sfx(tmpscr->secretsfx);
26194 action=rafting; FFCore.setHeroAction(rafting);
26195 raftclk=0;
26196 }
26197 7869 }
26198
26199 8247 opendoors=0;
26200 8247 markBmap(-1);
26201
26202
2/2
✓ Branch 0 taken 4761 times.
✓ Branch 1 taken 3486 times.
8247 if(isdungeon())
26203 {
26204
3/3
✓ Branch 0 taken 1875 times.
✓ Branch 1 taken 1012 times.
✓ Branch 2 taken 599 times.
3486 switch(tmpscr->door[scrolldir^1])
26205 {
26206 case dOPEN:
26207 case dUNLOCKED:
26208 case dOPENBOSS:
26209 1875 dir = scrolldir;
26210
26211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1875 times.
1875 if(action!=rafting)
26212 1875 stepforward(diagonalMovement?11:12, false);
26213
26214 1875 break;
26215
26216 case dSHUTTER:
26217 case d1WAYSHUTTER:
26218 1012 dir = scrolldir;
26219
26220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1012 times.
1012 if(action!=rafting)
26221 1012 stepforward(diagonalMovement?21:24, false);
26222
26223 1012 putdoor(scrollbuf,0,scrolldir^1,tmpscr->door[scrolldir^1]);
26224 1012 opendoors=-4;
26225 1012 sfx(WAV_DOOR);
26226 1012 break;
26227
26228 default:
26229 599 dir = scrolldir;
26230
26231
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 552 times.
599 if(action!=rafting)
26232 552 stepforward(diagonalMovement?21:24, false);
26233 599 }
26234 3486 }
26235
26236
1/2
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
8247 if(action == scrolling)
26237 {
26238 action=none; FFCore.setHeroAction(none);
26239 }
26240
26241
2/4
✓ Branch 0 taken 8247 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8247 times.
8247 if(action != attacking && action != sideswimattacking)
26242 {
26243 8247 charging = 0;
26244 8247 tapping = false;
26245 8247 }
26246
26247 8247 map_bkgsfx(true);
26248
26249
2/2
✓ Branch 0 taken 8229 times.
✓ Branch 1 taken 18 times.
8247 if(newscr->flags2&fSECRET)
26250 {
26251 18 sfx(newscr->secretsfx);
26252 18 }
26253
26254 8247 playLevelMusic();
26255
26256 8247 newscr_clk = frame;
26257 8247 activated_timed_warp=false;
26258 8247 loadside = scrolldir^1;
26259 8247 FFCore.init_combo_doscript();
26260 8247 eventlog_mapflags();
26261 8247 decorations.animate(); //continue to animate tall grass during scrolling
26262
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 8017 times.
8247 if(get_bit(quest_rules,qr_FIXSCRIPTSDURINGSCROLLING))
26263 {
26264 230 ZScriptVersion::RunScrollingScript(scrolldir, cx, sx, sy, end_frames, false); //Prewaitdraw
26265 230 }
26266 8247 }
26267
26268
26269
26270 // How much to reduce Hero's damage, taking into account various rings.
26271 5665 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
26272 {
26273
1/2
✓ Branch 0 taken 5665 times.
✗ Branch 1 not taken.
5665 if(dmg < 0) return dmg; //Don't reduce healing
26274
2/2
✓ Branch 0 taken 5533 times.
✓ Branch 1 taken 132 times.
5665 if ( get_bit(quest_rules,qr_BROKEN_RING_POWER) )
26275 {
26276 5533 int32_t divisor = 1;
26277 5533 float percentage = 1;
26278 5533 int32_t itemid = current_item_id(itype_ring);
26279 5533 bool usering = false;
26280
26281
4/4
✓ Branch 0 taken 4331 times.
✓ Branch 1 taken 1202 times.
✓ Branch 2 taken 37 times.
✓ Branch 3 taken 4294 times.
5533 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26282 {
26283 4294 usering = true;
26284 4294 paymagiccost(itemid);
26285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4294 times.
4294 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26286 {
26287 percentage *= itemsbuf[itemid].power/100.0;
26288 }
26289 else
26290 {
26291 4294 divisor *= itemsbuf[itemid].power;
26292 }
26293 4294 }
26294
26295 /* Now for the Peril Ring */
26296 5533 itemid = current_item_id(itype_perilring);
26297
26298
7/10
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 5099 times.
✓ Branch 2 taken 434 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 427 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7 times.
5533 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26299 {
26300 7 usering = true;
26301 7 paymagiccost(itemid);
26302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26303 {
26304 percentage *= itemsbuf[itemid].power/100.0;
26305 }
26306 else
26307 {
26308 7 divisor *= itemsbuf[itemid].power;
26309 }
26310 7 }
26311
26312 // Ring divisor of 0 = no damage. -L
26313
4/6
✓ Branch 0 taken 4301 times.
✓ Branch 1 taken 1232 times.
✓ Branch 2 taken 4301 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4301 times.
5533 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26314 return 0;
26315
26316
1/2
✓ Branch 0 taken 5533 times.
✗ Branch 1 not taken.
5533 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
26317
26318
1/2
✓ Branch 0 taken 5533 times.
✗ Branch 1 not taken.
5533 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
26319
1/2
✓ Branch 0 taken 5533 times.
✗ Branch 1 not taken.
5533 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26320
26321 }
26322 else
26323 {
26324 132 double divisor = 1;
26325 132 double percentage = 1;
26326 132 int32_t itemid = current_item_id(itype_ring);
26327 132 bool usering = false;
26328
26329
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
132 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
26330 {
26331 3 usering = true;
26332 3 paymagiccost(itemid);
26333
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26334 {
26335 1 double perc = itemsbuf[itemid].power/100.0;
26336
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26337 1 percentage *= perc;
26338 1 }
26339 else
26340 {
26341
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].power < 0)
26342 divisor /= -(itemsbuf[itemid].power);
26343 2 else divisor *= itemsbuf[itemid].power;
26344 }
26345 3 }
26346
26347 /* Now for the Peril Ring */
26348 132 itemid = current_item_id(itype_perilring);
26349
26350
4/10
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
132 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
26351 {
26352 usering = true;
26353 paymagiccost(itemid);
26354 if(itemsbuf[itemid].flags & ITEM_FLAG2)//"Divisor is Percentage Multiplier" flag
26355 {
26356 double perc = itemsbuf[itemid].power/100.0;
26357 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
26358 percentage *= perc;
26359 }
26360 else
26361 {
26362 if(itemsbuf[itemid].power < 0)
26363 divisor /= -(itemsbuf[itemid].power);
26364 else divisor *= itemsbuf[itemid].power;
26365 }
26366 }
26367
26368 // Ring divisor of 0 = no damage. -L
26369
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
132 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
26370 return 0;
26371
26372 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
26373
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
26374 }
26375 5665 }
26376
26377 // Should swinging the hammer make the 'pound' sound?
26378 // Or is Hero just hitting air?
26379 285 bool HeroClass::sideviewhammerpound()
26380 {
26381 285 int32_t wx=0,wy=0;
26382
26383
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 132 times.
285 switch(dir)
26384 {
26385 case up:
26386 81 wx=-1;
26387 81 wy=-15;
26388
26389
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(isSideViewHero()) wy+=8;
26390
26391 81 break;
26392
26393 case down:
26394 54 wx=8;
26395 54 wy=28;
26396
26397
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(isSideViewHero()) wy-=8;
26398
26399 54 break;
26400
26401 case left:
26402 18 wx=-8;
26403 18 wy=14;
26404
26405
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 if(isSideViewHero()) wy+=8;
26406
26407 18 break;
26408
26409 case right:
26410 132 wx=21;
26411 132 wy=14;
26412
26413
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(isSideViewHero()) wy+=8;
26414
26415 132 break;
26416 }
26417
26418
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 279 times.
285 if(!isSideViewHero())
26419 {
26420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex(MAPCOMBO(x+wx,y+wy), currmap, currscr, -1, x+wx,y+wy));
26421 }
26422
26423
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26424
26425 if(dir==left || dir==right)
26426 {
26427 wx+=16;
26428
26429 if(_walkflag(x+wx,y+wy,0,SWITCHBLOCK_STATE)) return true;
26430 }
26431
26432 return false;
26433 285 }
26434
26435 /************************************/
26436 /******** More Items Code *********/
26437 /************************************/
26438
26439 // The following are only used for Hero damage. Damage is in quarter hearts.
26440 3055 int32_t enemy_dp(int32_t index)
26441 {
26442 3055 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
26443 }
26444
26445 2479 int32_t ewpn_dp(int32_t index)
26446 {
26447 2479 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
26448 }
26449
26450 20 int32_t lwpn_dp(int32_t index)
26451 {
26452 20 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
26453 }
26454
26455 77578703 bool checkbunny(int32_t itemid)
26456 {
26457
3/4
✓ Branch 0 taken 77474037 times.
✓ Branch 1 taken 104666 times.
✓ Branch 2 taken 104666 times.
✗ Branch 3 not taken.
77578703 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&ITEM_BUNNY_ENABLED);
26458 }
26459
26460 18260676 bool usesSwordJinx(int32_t itemid)
26461 {
26462 18260676 itemdata const& it = itemsbuf[itemid];
26463 18260676 bool ret = (it.family==itype_sword);
26464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18260676 times.
18260676 if(it.flags & ITEM_FLIP_JINX) return !ret;
26465 18260676 return ret;
26466 18260676 }
26467 16085166 bool checkitem_jinx(int32_t itemid)
26468 {
26469 16085166 itemdata const& it = itemsbuf[itemid];
26470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16085166 times.
16085166 if(it.flags & ITEM_JINX_IMMUNE) return true;
26471
2/2
✓ Branch 0 taken 4406617 times.
✓ Branch 1 taken 11678549 times.
16085166 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
26472 11678549 return HeroItemClk() == 0;
26473 16085166 }
26474
26475 304117 int32_t Bweapon(int32_t pos)
26476 {
26477
4/4
✓ Branch 0 taken 304116 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 303440 times.
304117 if(pos < 0 || current_subscreen_active == NULL)
26478 {
26479 677 return 0;
26480 }
26481
26482 303440 int32_t p=-1;
26483
26484
4/4
✓ Branch 0 taken 80664 times.
✓ Branch 1 taken 8824665 times.
✓ Branch 2 taken 80664 times.
✓ Branch 3 taken 8824665 times.
8905329 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL && i < MAXSUBSCREENITEMS; ++i)
26485 {
26486
4/4
✓ Branch 0 taken 6326332 times.
✓ Branch 1 taken 2498333 times.
✓ Branch 2 taken 6103556 times.
✓ Branch 3 taken 222776 times.
8824665 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM && current_subscreen_active->objects[i].d3==pos)
26487 {
26488 222776 p=i;
26489 222776 break;
26490 }
26491 8601889 }
26492
26493
2/2
✓ Branch 0 taken 222776 times.
✓ Branch 1 taken 80664 times.
303440 if(p==-1)
26494 {
26495 80664 return 0;
26496 }
26497
26498 222776 int32_t actualItem = current_subscreen_active->objects[p].d8;
26499 //int32_t familyCheck = actualItem ? itemsbuf[actualItem].family : current_subscreen_active->objects[p].d1
26500 222776 int32_t family = -1;
26501 222776 bool bow = false;
26502
26503
2/2
✓ Branch 0 taken 9486 times.
✓ Branch 1 taken 213290 times.
222776 if(actualItem)
26504 {
26505 9486 bool select = false;
26506
26507
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6222 times.
9486 switch(itemsbuf[actualItem-1].family)
26508 {
26509 case itype_bomb:
26510 if((game->get_bombs() ||
26511 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26512 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitBomb))) ||
26513 current_item_power(itype_bombbag))
26514 {
26515 select=true;
26516 }
26517
26518 break;
26519
26520 case itype_bowandarrow:
26521 case itype_arrow:
26522 if(actualItem-1>-1 && current_item_id(itype_bow)>-1)
26523 {
26524 //bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26525 select=true;
26526 }
26527
26528 break;
26529
26530 case itype_letterpotion:
26531 /*if(current_item_id(itype_potion)>-1)
26532 {
26533 select=true;
26534 }
26535 else if(current_item_id(itype_letter)>-1)
26536 {
26537 select=true;
26538 }*/
26539 break;
26540
26541 case itype_sbomb:
26542 {
26543 int32_t bombbagid = current_item_id(itype_bombbag);
26544
26545 if((game->get_sbombs() ||
26546 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26547 (actualItem-1>-1 && itemsbuf[actualItem-1].misc1==0 && findWeaponWithParent(actualItem-1, wLitSBomb))) ||
26548 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26549 {
26550 select=true;
26551 }
26552
26553 break;
26554 }
26555
26556 case itype_sword:
26557 {
26558
1/2
✓ Branch 0 taken 6222 times.
✗ Branch 1 not taken.
6222 if(!get_bit(quest_rules,qr_SELECTAWPN))
26559 break;
26560
26561 6222 select=true;
26562 }
26563 6222 break;
26564
26565 default:
26566 3264 select=true;
26567 3264 }
26568
26569
4/6
✓ Branch 0 taken 9486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✓ Branch 3 taken 1867 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7619 times.
9486 if(!item_disabled(actualItem-1) && game->get_item(actualItem-1) && select)
26570 {
26571 7619 directItem = actualItem-1;
26572
26573
2/4
✓ Branch 0 taken 7619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7619 times.
✗ Branch 3 not taken.
7619 if(directItem>-1 && itemsbuf[directItem].family == itype_arrow) bow=true;
26574
26575 7619 return actualItem-1+(bow?0xF000:0);
26576 }
26577 1867 else return 0;
26578 }
26579
26580 213290 directItem = -1;
26581
26582
6/6
✓ Branch 0 taken 20067 times.
✓ Branch 1 taken 1893 times.
✓ Branch 2 taken 178647 times.
✓ Branch 3 taken 8026 times.
✓ Branch 4 taken 3190 times.
✓ Branch 5 taken 1467 times.
213290 switch(current_subscreen_active->objects[p].d1)
26583 {
26584 case itype_bomb:
26585 {
26586 20067 int32_t bombid = current_item_id(itype_bomb);
26587
26588
4/4
✓ Branch 0 taken 4942 times.
✓ Branch 1 taken 15125 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 4909 times.
25009 if((game->get_bombs() ||
26589 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26590
3/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 4862 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
4942 (bombid>-1 && itemsbuf[bombid].misc1==0 && Lwpns.idCount(wLitBomb)>0)) ||
26591 4942 current_item_power(itype_bombbag))
26592 {
26593 15158 family=itype_bomb;
26594 15158 }
26595
26596 20067 break;
26597 }
26598
26599 case itype_bowandarrow:
26600 case itype_arrow:
26601
4/4
✓ Branch 0 taken 6994 times.
✓ Branch 1 taken 1032 times.
✓ Branch 2 taken 6993 times.
✓ Branch 3 taken 1 times.
8026 if(current_item_id(itype_bow)>-1 && current_item_id(itype_arrow)>-1)
26602 {
26603 6993 bow=(current_subscreen_active->objects[p].d1==itype_bowandarrow);
26604 6993 family=itype_arrow;
26605 6993 }
26606
26607 8026 break;
26608
26609 case itype_letterpotion:
26610
2/2
✓ Branch 0 taken 1999 times.
✓ Branch 1 taken 1191 times.
3190 if(current_item_id(itype_potion)>-1)
26611 {
26612 1999 family=itype_potion;
26613 1999 }
26614
2/2
✓ Branch 0 taken 919 times.
✓ Branch 1 taken 272 times.
1191 else if(current_item_id(itype_letter)>-1)
26615 {
26616 272 family=itype_letter;
26617 272 }
26618
26619 3190 break;
26620
26621 case itype_sbomb:
26622 {
26623 1893 int32_t bombbagid = current_item_id(itype_bombbag);
26624 1893 int32_t sbombid = current_item_id(itype_sbomb);
26625
26626
3/4
✓ Branch 0 taken 696 times.
✓ Branch 1 taken 1197 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
1903 if((game->get_sbombs() ||
26627 // Remote Bombs: the bomb icon can still be used when an undetonated bomb is onscreen.
26628
3/4
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 628 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
696 (sbombid>-1 && itemsbuf[sbombid].misc1==0 && Lwpns.idCount(wLitSBomb)>0)) ||
26629
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 686 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
696 (current_item_power(itype_bombbag) && bombbagid>-1 && (itemsbuf[bombbagid].flags & ITEM_FLAG1)))
26630 {
26631 1207 family=itype_sbomb;
26632 1207 }
26633
26634 1893 break;
26635 }
26636
26637 case itype_sword:
26638 {
26639
2/2
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 30 times.
1467 if(!get_bit(quest_rules,qr_SELECTAWPN))
26640 30 break;
26641
26642 1437 family=itype_sword;
26643 }
26644 1437 break;
26645
26646 default:
26647 178647 family=current_subscreen_active->objects[p].d1;
26648 178647 }
26649
26650
2/2
✓ Branch 0 taken 205713 times.
✓ Branch 1 taken 7577 times.
213290 if(family==-1)
26651 7577 return 0;
26652
26653
2/2
✓ Branch 0 taken 9514006 times.
✓ Branch 1 taken 12228 times.
9526234 for(int32_t j=0; j<MAXITEMS; j++)
26654 {
26655 // Find the item that matches this subscreen object.
26656
5/6
✓ Branch 0 taken 362131 times.
✓ Branch 1 taken 9151875 times.
✓ Branch 2 taken 193485 times.
✓ Branch 3 taken 168646 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 193485 times.
9514006 if(itemsbuf[j].family==family && j == current_item_id(family,false) && !item_disabled(j))
26657 {
26658 193485 return j+(bow?0xF000:0);
26659 }
26660 9320521 }
26661
26662 12228 return 0;
26663 304117 }
26664
26665 93 int32_t BWeapon_to_Pos(int32_t bweapon)
26666 {
26667
2/2
✓ Branch 0 taken 5272 times.
✓ Branch 1 taken 19 times.
5291 for (int32_t i = 0; i < MAXSUBSCREENITEMS; ++i)
26668 {
26669
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 5198 times.
5272 if (Bweapon(i) == bweapon)
26670 {
26671 74 return i;
26672 }
26673 5198 }
26674 19 return -1;
26675 93 }
26676
26677 2 void stopCaneOfByrna()
26678 {
26679
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
42 for(int32_t i=0; i<Lwpns.Count(); i++)
26680 {
26681 40 weapon *w = ((weapon*)Lwpns.spr(i));
26682
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 2 times.
40 if(w->id==wCByrna)
26683 2 w->dead=1;
26684 40 }
26685 2 }
26686
26687 /* Crashes if used by ffscript.cpp, in case LINKITEMD
26688 void stopCaneOfByrna()
26689 {
26690 byte prnt_cane = -1;
26691 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
26692 prnt_cane = ew->parentitem;
26693 for(int32_t i=0; i<Lwpns.Count(); i++)
26694 {
26695 weapon *w = ((weapon*)Lwpns.spr(i));
26696
26697 if(w->id==wCByrna)
26698 {
26699 w->dead=1;
26700 }
26701 }
26702 if ( prnt_cane > -1 )
26703 {
26704 stop_sfx(itemsbuf[prnt_cane].usesound);
26705 }
26706 }
26707 */
26708 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
26709 5150916 void HeroClass::cleanupByrna()
26710 {
26711
2/2
✓ Branch 0 taken 5150839 times.
✓ Branch 1 taken 77 times.
5150916 if ( last_cane_of_byrna_item_id > -1 )
26712 {
26713 //al_trace("Last cane id is: %d\n", last_cane_of_byrna_item_id);
26714
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 75 times.
77 if ( !(Lwpns.idCount(wCByrna)) )
26715 {
26716 2 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
26717 2 last_cane_of_byrna_item_id = -1;
26718 2 }
26719 77 }
26720 5150916 }
26721
26722 // Used to find out if an item family is attached to one of the buttons currently pressed.
26723 1939314 bool isWpnPressed(int32_t itype)
26724 {
26725 //0xFFF for subscreen overrides
26726 //Will crash on win10 without it! -Z
26727
4/4
✓ Branch 0 taken 378142 times.
✓ Branch 1 taken 1561172 times.
✓ Branch 2 taken 349340 times.
✓ Branch 3 taken 28802 times.
1939314 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return true;
26728
4/4
✓ Branch 0 taken 606407 times.
✓ Branch 1 taken 1304105 times.
✓ Branch 2 taken 221443 times.
✓ Branch 3 taken 384964 times.
1910512 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return true;
26729
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1525548 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1525548 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return true;
26730
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1525528 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
1525548 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return true;
26731 1525528 return false;
26732 1939314 }
26733
26734 3658699 int32_t getWpnPressed(int32_t itype)
26735 {
26736
4/4
✓ Branch 0 taken 177199 times.
✓ Branch 1 taken 3481500 times.
✓ Branch 2 taken 171856 times.
✓ Branch 3 taken 5343 times.
3658699 if((itype==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26737
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 3652770 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 586 times.
3653356 if((itype==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26738
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3652770 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3652770 if((itype==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26739
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3652770 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3652770 if((itype==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26740
26741 3652770 return -1;
26742 3658699 }
26743
26744 5152513 int32_t getRocsPressed()
26745 {
26746 5152513 int32_t jumpid = current_item_id(itype_rocs,true,true);
26747
26748
2/2
✓ Branch 0 taken 195658 times.
✓ Branch 1 taken 4956855 times.
5152513 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
26749
26750
2/2
✓ Branch 0 taken 4956855 times.
✓ Branch 1 taken 195658 times.
5152513 if (jumpid != -1)
26751 {
26752 195658 itemdata const& itm = itemsbuf[jumpid];
26753
26754 195658 byte intbtn = byte(itm.misc2&0xFF);
26755
1/2
✓ Branch 0 taken 195658 times.
✗ Branch 1 not taken.
195658 if(getIntBtnInput(intbtn, false, true, false, false, true))
26756 return jumpid; //not pressed
26757 195658 }
26758
26759
4/4
✓ Branch 0 taken 15394 times.
✓ Branch 1 taken 5137119 times.
✓ Branch 2 taken 14327 times.
✓ Branch 3 taken 1067 times.
5152513 if((itype_rocs==getItemFamily(itemsbuf,Bwpn&0xFFF)) && DrunkcBbtn()) return Bwpn;
26760
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5151446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5151446 if((itype_rocs==getItemFamily(itemsbuf,Awpn&0xFFF)) && DrunkcAbtn()) return Awpn;
26761
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5151446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5151446 if((itype_rocs==getItemFamily(itemsbuf,Xwpn&0xFFF)) && DrunkcEx1btn()) return Xwpn;
26762
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5151446 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5151446 if((itype_rocs==getItemFamily(itemsbuf,Ywpn&0xFFF)) && DrunkcEx2btn()) return Ywpn;
26763
26764 5151446 return -1;
26765 5152513 }
26766
26767 bool isItmPressed(int32_t itmid)
26768 {
26769 if(itmid==(Bwpn&0xFFF) && DrunkcBbtn()) return true;
26770 if(itmid==(Awpn&0xFFF) && DrunkcAbtn()) return true;
26771 if(itmid==(Xwpn&0xFFF) && DrunkcEx1btn()) return true;
26772 if(itmid==(Ywpn&0xFFF) && DrunkcEx2btn()) return true;
26773 return false;
26774 }
26775
26776 781 void selectNextAWpn(int32_t type)
26777 {
26778
1/2
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
781 if(!get_bit(quest_rules,qr_SELECTAWPN))
26779 return;
26780
26781
2/4
✓ Branch 0 taken 781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 781 times.
✗ Branch 3 not taken.
781 int32_t ret = selectWpn_new(type, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26782 781 Awpn = Bweapon(ret);
26783 781 directItemA = directItem;
26784 781 game->awpn = ret;
26785 781 }
26786
26787 5938 void selectNextBWpn(int32_t type)
26788 {
26789
2/4
✓ Branch 0 taken 5938 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5938 times.
5938 int32_t ret = selectWpn_new(type, game->bwpn, game->awpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26790 5938 Bwpn = Bweapon(ret);
26791 5938 directItemB = directItem;
26792 5938 game->bwpn = ret;
26793 5938 }
26794
26795 void selectNextXWpn(int32_t type)
26796 {
26797 if(!get_bit(quest_rules,qr_SET_XBUTTON_ITEMS)) return;
26798 int32_t ret = selectWpn_new(type, game->xwpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_YBUTTON_ITEMS) ? game->ywpn : -1);
26799 Xwpn = Bweapon(ret);
26800 directItemX = directItem;
26801 game->xwpn = ret;
26802 }
26803
26804 void selectNextYWpn(int32_t type)
26805 {
26806 if(!get_bit(quest_rules,qr_SET_YBUTTON_ITEMS)) return;
26807 int32_t ret = selectWpn_new(type, game->ywpn, game->awpn, game->bwpn, get_bit(quest_rules,qr_SET_XBUTTON_ITEMS) ? game->xwpn : -1);
26808 Ywpn = Bweapon(ret);
26809 directItemY = directItem;
26810 game->ywpn = ret;
26811 }
26812
26813 40193 void verifyAWpn()
26814 {
26815
2/2
✓ Branch 0 taken 1021 times.
✓ Branch 1 taken 39172 times.
40193 if ( (game->forced_awpn != -1) )
26816 {
26817 1021 return;
26818 }
26819
2/2
✓ Branch 0 taken 36029 times.
✓ Branch 1 taken 3143 times.
39172 if(!get_bit(quest_rules,qr_SELECTAWPN))
26820 {
26821 36029 Awpn = selectSword();
26822 36029 game->awpn = 0xFF;
26823 36029 }
26824 else
26825 {
26826 3143 game->awpn = selectWpn_new(SEL_VERIFY_RIGHT, game->awpn, game->bwpn, game->xwpn, game->ywpn);
26827 3143 Awpn = Bweapon(game->awpn);
26828 3143 directItemA = directItem;
26829 }
26830 40193 }
26831
26832 38315 void verifyBWpn()
26833 {
26834
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 37300 times.
38315 if ( (game->forced_bwpn != -1) )
26835 {
26836 1015 return;
26837 }
26838 37300 game->bwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->bwpn, game->awpn, game->xwpn, game->ywpn);
26839 37300 Bwpn = Bweapon(game->bwpn);
26840 37300 directItemB = directItem;
26841 38315 }
26842
26843 38315 void verifyXWpn()
26844 {
26845
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 37300 times.
38315 if ( (game->forced_xwpn != -1) )
26846 {
26847 1015 return;
26848 }
26849
2/2
✓ Branch 0 taken 37236 times.
✓ Branch 1 taken 64 times.
37300 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
26850 64 game->xwpn = selectWpn_new(SEL_VERIFY_RIGHT, game->xwpn, game->awpn, game->bwpn, game->ywpn);
26851 37236 else game->xwpn = -1;
26852 37300 Xwpn = Bweapon(game->xwpn);
26853 37300 directItemX = directItem;
26854 38315 }
26855
26856 38315 void verifyYWpn()
26857 {
26858
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 37300 times.
38315 if ( (game->forced_ywpn != -1) )
26859 {
26860 1015 return;
26861 }
26862
2/2
✓ Branch 0 taken 37236 times.
✓ Branch 1 taken 64 times.
37300 if(get_bit(quest_rules,qr_SET_YBUTTON_ITEMS))
26863 64 game->ywpn = selectWpn_new(SEL_VERIFY_RIGHT, game->ywpn, game->awpn, game->xwpn, game->bwpn);
26864 37236 else game->ywpn = -1;
26865 37300 Ywpn = Bweapon(game->ywpn);
26866 37300 directItemY = directItem;
26867 38315 }
26868
26869 38315 void verifyBothWeapons()
26870 {
26871 38315 verifyAWpn();
26872 38315 verifyBWpn();
26873 38315 verifyXWpn();
26874 38315 verifyYWpn();
26875 38315 }
26876
26877 48729 int32_t selectWpn_new(int32_t type, int32_t startpos, int32_t forbiddenpos, int32_t fp2, int32_t fp3)
26878 {
26879 //what will be returned when all else fails.
26880 //don't return the forbiddenpos... no matter what -DD
26881
26882 48729 int32_t failpos(0);
26883
26884
6/6
✓ Branch 0 taken 47967 times.
✓ Branch 1 taken 762 times.
✓ Branch 2 taken 47810 times.
✓ Branch 3 taken 157 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 47806 times.
48729 if(startpos == forbiddenpos || startpos == fp2 || startpos == fp3)
26885 923 failpos = 0xFF;
26886 47806 else failpos = startpos;
26887
26888 // verify startpos
26889
3/4
✓ Branch 0 taken 48729 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 934 times.
✓ Branch 3 taken 47795 times.
48729 if(startpos < 0 || startpos >= 0xFF)
26890 934 startpos = 0;
26891
26892
2/2
✓ Branch 0 taken 48491 times.
✓ Branch 1 taken 238 times.
48729 if(current_subscreen_active == NULL)
26893 238 return failpos;
26894
26895
4/4
✓ Branch 0 taken 8058 times.
✓ Branch 1 taken 40433 times.
✓ Branch 2 taken 583 times.
✓ Branch 3 taken 7475 times.
48491 if(type==SEL_VERIFY_RIGHT || type==SEL_VERIFY_LEFT)
26896 {
26897 41016 int32_t wpn = Bweapon(startpos);
26898
26899
6/8
✓ Branch 0 taken 39479 times.
✓ Branch 1 taken 1537 times.
✓ Branch 2 taken 39458 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 39458 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 39458 times.
41016 if(wpn != 0 && startpos != forbiddenpos && startpos != fp2 && startpos != fp3)
26900 {
26901 39458 return startpos;
26902 }
26903 1558 }
26904
26905 9033 int32_t p=-1;
26906 9033 int32_t curpos = startpos;
26907 9033 int32_t firstValidPos=-1;
26908
26909
2/2
✓ Branch 0 taken 744 times.
✓ Branch 1 taken 214937 times.
215681 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26910 {
26911
2/2
✓ Branch 0 taken 60770 times.
✓ Branch 1 taken 154167 times.
214937 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26912 {
26913
4/4
✓ Branch 0 taken 118322 times.
✓ Branch 1 taken 35845 times.
✓ Branch 2 taken 110033 times.
✓ Branch 3 taken 8289 times.
154167 if(firstValidPos==-1 && current_subscreen_active->objects[i].d3>=0)
26914 {
26915 8289 firstValidPos=i;
26916 8289 }
26917
26918
2/2
✓ Branch 0 taken 145878 times.
✓ Branch 1 taken 8289 times.
154167 if(current_subscreen_active->objects[i].d3==curpos)
26919 {
26920 8289 p=i;
26921 8289 break;
26922 }
26923 145878 }
26924 206648 }
26925
26926
2/2
✓ Branch 0 taken 8289 times.
✓ Branch 1 taken 744 times.
9033 if(p == -1)
26927 {
26928 //can't find the current position
26929 // Switch to a valid weapon if there is one; otherwise,
26930 // the selector can simply disappear
26931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 744 times.
744 if(firstValidPos>=0)
26932 {
26933 return current_subscreen_active->objects[firstValidPos].d3;
26934 }
26935 //FAILURE
26936 else
26937 {
26938 744 return failpos;
26939 }
26940 }
26941
26942 //remember we've been here
26943 8289 set<int32_t> oldPositions;
26944
1/2
✓ Branch 0 taken 8289 times.
✗ Branch 1 not taken.
8289 oldPositions.insert(curpos);
26945
26946 //1. Perform any shifts required by the above
26947 //2. If that's not possible, go to position 1 and reset the b weapon.
26948 //2a. -if we arrive at a position we've already visited, give up and stay there
26949 //3. Get the weapon at the new slot
26950 //4. If it's not possible, go to step 1.
26951
26952 24798 for(;;)
26953 {
26954 //shift
26955
4/5
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 3920 times.
✓ Branch 3 taken 20772 times.
✗ Branch 4 not taken.
24798 switch(type)
26956 {
26957 case SEL_LEFT:
26958 case SEL_VERIFY_LEFT:
26959 3920 curpos = current_subscreen_active->objects[p].d6;
26960 3920 break;
26961
26962 case SEL_RIGHT:
26963 case SEL_VERIFY_RIGHT:
26964 20772 curpos = current_subscreen_active->objects[p].d7;
26965 20772 break;
26966
26967 case SEL_DOWN:
26968 31 curpos = current_subscreen_active->objects[p].d5;
26969 31 break;
26970
26971 case SEL_UP:
26972 75 curpos = current_subscreen_active->objects[p].d4;
26973 75 break;
26974 }
26975
26976 //find our new position
26977 24798 p = -1;
26978
26979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 825528 times.
825528 for(int32_t i=0; current_subscreen_active->objects[i].type!=ssoNULL; ++i)
26980 {
26981
2/2
✓ Branch 0 taken 179176 times.
✓ Branch 1 taken 646352 times.
825528 if(current_subscreen_active->objects[i].type==ssoCURRENTITEM)
26982 {
26983
2/2
✓ Branch 0 taken 621554 times.
✓ Branch 1 taken 24798 times.
646352 if(current_subscreen_active->objects[i].d3==curpos)
26984 {
26985 24798 p=i;
26986 24798 break;
26987 }
26988 621554 }
26989 800730 }
26990
26991
1/2
✓ Branch 0 taken 24798 times.
✗ Branch 1 not taken.
24798 if(p == -1)
26992 {
26993 //can't find the current position
26994 //FAILURE
26995 return failpos;
26996 }
26997
26998 //if we've already been here, give up
26999
3/4
✓ Branch 0 taken 24798 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23730 times.
✓ Branch 3 taken 1068 times.
24798 if(oldPositions.find(curpos) != oldPositions.end())
27000 {
27001 1068 return failpos;
27002 }
27003
27004 //else, remember we've been here
27005
1/2
✓ Branch 0 taken 23730 times.
✗ Branch 1 not taken.
23730 oldPositions.insert(curpos);
27006
27007 //see if this weapon is acceptable
27008
9/10
✓ Branch 0 taken 23730 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7450 times.
✓ Branch 3 taken 16280 times.
✓ Branch 4 taken 7239 times.
✓ Branch 5 taken 211 times.
✓ Branch 6 taken 7229 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 7221 times.
23730 if(Bweapon(curpos) != 0 && curpos != forbiddenpos && curpos != fp2 && curpos != fp3)
27009 7221 return curpos;
27010
27011 //keep going otherwise
27012 }
27013 48729 }
27014
27015 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
27016 36119 int32_t selectSword()
27017 {
27018 36119 auto ret = current_item_id(itype_sword);
27019
2/2
✓ Branch 0 taken 980 times.
✓ Branch 1 taken 35139 times.
36119 if(ret == -1) return 0;
27020 35139 return ret;
27021 36119 }
27022
27023 // Adding code here for allowing hardcoding a button to a specific itemclass.
27024 int32_t selectItemclass(int32_t itemclass)
27025 {
27026 int32_t ret = current_item_id(itemclass);
27027
27028 if(ret == -1)
27029 ret = 0;
27030
27031 return ret;
27032 }
27033
27034 // Used for the 'Pickup Hearts' item pickup condition.
27035 71 bool canget(int32_t id)
27036 {
27037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
27038 }
27039
27040 27 void dospecialmoney(int32_t index)
27041 {
27042 27 int32_t tmp=currscr>=128?1:0;
27043 27 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
27044
27045
4/7
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
27 switch(tmpscr[tmp].room)
27046 {
27047 case rINFO: // pay for info
27048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
27049 {
27050
27051
27052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!current_item_power(itype_wallet))
27053 {
27054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (game->get_spendable_rupies() < abs(prices[priceindex]))
27055 return;
27056 1 int32_t tmpprice = -abs(prices[priceindex]);
27057 1 int32_t total = game->get_drupy()-tmpprice;
27058 1 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27059 1 game->set_drupy(game->get_drupy()-total);
27060 //game->change_drupy(-abs(prices[priceindex]));
27061 1 }
27062
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if ( current_item_power(itype_wallet)>0 )
27063 {
27064 game->change_drupy(0);
27065 }
27066 1 }
27067 1 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
27068 1 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
27069 1 donewmsg(QMisc.info[tmpscr[tmp].catchall].str[priceindex]);
27070 1 clear_bitmap(pricesdisplaybuf);
27071 1 set_clip_state(pricesdisplaybuf, 1);
27072 1 items.del(0);
27073
27074
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<items.Count(); i++)
27075 3 ((item*)items.spr(i))->pickup=ipDUMMY;
27076
27077 // Prevent the prices from being displayed anymore
27078
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<3; i++)
27079 {
27080 3 prices[i] = 0;
27081 3 }
27082
27083 1 break;
27084
27085 case rMONEY: // secret money
27086 {
27087 12 ((item*)items.spr(0))->pickup = ipDUMMY;
27088
27089 12 prices[0] = tmpscr[tmp].catchall;
27090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (!current_item_power(itype_wallet))
27091 12 game->change_drupy(prices[0]);
27092 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
27093
27094 12 putprices(false);
27095
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27096 12 break;
27097 }
27098
27099 case rGAMBLE: // gamble
27100 {
27101 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
27102
27103 unsigned si=(zc_oldrand()%24)*3;
27104
27105 for(int32_t i=0; i<3; i++)
27106 prices[i]=gambledat[si++];
27107
27108 game->set_drupy(game->get_drupy()+prices[priceindex]);
27109 putprices(true);
27110
27111 for(int32_t i=1; i<4; i++)
27112 ((item*)items.spr(i))->pickup=ipDUMMY;
27113 }
27114 break;
27115
27116 case rBOMBS:
27117 {
27118
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
27119 return;
27120
27121 3 int32_t price = -tmpscr[tmp].catchall;
27122 3 int32_t wmedal = current_item_id(itype_wealthmedal);
27123
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(wmedal >= 0)
27124 {
27125 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
27126 price*=(itemsbuf[wmedal].misc1/100.0);
27127 else
27128 price+=itemsbuf[wmedal].misc1;
27129 }
27130
27131 3 int32_t total = game->get_drupy()-price;
27132 3 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27133 3 game->set_drupy(game->get_drupy()-total);
27134 //game->set_drupy(game->get_drupy()+price);
27135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27136 3 game->change_maxbombs(4);
27137 3 game->set_bombs(game->get_maxbombs());
27138 {
27139 3 int32_t div = zinit.bomb_ratio;
27140
27141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(div > 0)
27142 3 game->change_maxcounter(4/div, 6);
27143 }
27144
27145 //also give Hero an actual Bomb item
27146
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 3 times.
771 for(int32_t i=0; i<MAXITEMS; i++)
27147 {
27148
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 763 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3 times.
768 if(itemsbuf[i].family == itype_bomb && itemsbuf[i].fam_type == 1)
27149 3 getitem(i, true, true);
27150 768 }
27151
27152 3 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
27153 3 fadeclk=66;
27154 3 dismissmsg();
27155 3 clear_bitmap(pricesdisplaybuf);
27156 3 set_clip_state(pricesdisplaybuf, 1);
27157 // putscr(scrollbuf,0,0,tmpscr);
27158 3 verifyBothWeapons();
27159 3 break;
27160 }
27161
27162 case rARROWS:
27163 {
27164 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
27165 return;
27166
27167 int32_t price = -tmpscr[tmp].catchall;
27168 int32_t wmedal = current_item_id(itype_wealthmedal);
27169 if(wmedal >= 0)
27170 {
27171 if(itemsbuf[wmedal].flags & ITEM_FLAG1)
27172 price*=(itemsbuf[wmedal].misc1/100.0);
27173 else
27174 price+=itemsbuf[wmedal].misc1;
27175 }
27176
27177 int32_t total = game->get_drupy()-price;
27178 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27179 game->set_drupy(game->get_drupy()-total);
27180
27181 //game->set_drupy(game->get_drupy()+price);
27182 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27183 game->change_maxarrows(10);
27184 game->set_arrows(game->get_maxarrows());
27185 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
27186 fadeclk=66;
27187 dismissmsg();
27188 clear_bitmap(pricesdisplaybuf);
27189 set_clip_state(pricesdisplaybuf, 1);
27190 // putscr(scrollbuf,0,0,tmpscr);
27191 verifyBothWeapons();
27192 break;
27193 }
27194
27195 case rSWINDLE:
27196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(items.spr(index)->id==iRupy)
27197 {
27198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(game->get_spendable_rupies()<tmpscr[tmp].catchall && !current_item_power(itype_wallet))
27199 return;
27200 11 int32_t tmpprice = -tmpscr[tmp].catchall;
27201 11 int32_t total = game->get_drupy()-tmpprice;
27202 11 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27203 11 game->set_drupy(game->get_drupy()-total);
27204 11 }
27205 else
27206 {
27207 if(game->get_maxlife()<=game->get_hp_per_heart())
27208 return;
27209
27210 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
27211 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
27212 }
27213
27214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27215 11 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
27216 11 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
27217 11 fadeclk=66;
27218 11 dismissmsg();
27219 11 clear_bitmap(pricesdisplaybuf);
27220 11 set_clip_state(pricesdisplaybuf, 1);
27221 // putscr(scrollbuf,0,0,tmpscr);
27222 11 break;
27223 }
27224 27 }
27225
27226 7791 void getitem(int32_t id, bool nosound, bool doRunPassive)
27227 {
27228
1/2
✓ Branch 0 taken 7791 times.
✗ Branch 1 not taken.
7791 if(id<0)
27229 {
27230 return;
27231 }
27232
27233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7791 times.
7791 if (replay_is_active())
27234
1/2
✓ Branch 0 taken 7791 times.
✗ Branch 1 not taken.
7791 replay_step_comment(fmt::format("getitem {}", item_string[id]));
27235
27236
2/2
✓ Branch 0 taken 7785 times.
✓ Branch 1 taken 6 times.
7791 if(get_bit(quest_rules,qr_SCC_ITEM_COMBINES_ITEMS))
27237 {
27238 6 int32_t nextitem = -1;
27239 6 do
27240 {
27241 6 nextitem = -1;
27242
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if((itemsbuf[id].flags & ITEM_COMBINE) && game->get_item(id))
27243 // Item upgrade routine.
27244 {
27245
27246 for(int32_t i=0; i<MAXITEMS; i++)
27247 {
27248 // Find the item which is as close to this item's fam_type as possible.
27249 if(itemsbuf[i].family==itemsbuf[id].family && itemsbuf[i].fam_type>itemsbuf[id].fam_type
27250 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27251 {
27252 nextitem = i;
27253 }
27254 }
27255
27256 if(nextitem>-1)
27257 {
27258 id = nextitem;
27259 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27260 break; //no looping
27261 }
27262 }
27263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 } while(nextitem > -1);
27264 6 }
27265
27266 7791 itemdata const& idat = itemsbuf[id&0xFF];
27267 // if(idat.family!=0xFF) //1.92 compat... that already should be changed to 'itype_misc'? Blehg, hate this! -Em
27268 {
27269
4/4
✓ Branch 0 taken 802 times.
✓ Branch 1 taken 6989 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 759 times.
7791 if(idat.flags & ITEM_GAMEDATA && idat.family != itype_triforcepiece)
27270 {
27271 // Fix boomerang sounds.
27272 759 int32_t itemid = current_item_id(idat.family);
27273
27274
4/6
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 433 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
759 if(itemid>=0 && (idat.family == itype_brang || idat.family == itype_nayruslove
27275
5/6
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 432 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 431 times.
✓ Branch 5 taken 1 times.
433 || idat.family == itype_hookshot || idat.family == itype_switchhook || idat.family == itype_cbyrna)
27276 441 && sfx_allocated(itemsbuf[itemid].usesound)
27277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 441 times.
441 && idat.usesound != itemsbuf[itemid].usesound)
27278 {
27279 stop_sfx(itemsbuf[itemid].usesound);
27280 cont_sfx(idat.usesound);
27281 }
27282
27283 759 int32_t curitm = current_item_id(idat.family);
27284
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
759 if(!get_bit(quest_rules,qr_KEEPOLD_APPLIES_RETROACTIVELY)
27285
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
759 || curitm < 0 || (itemsbuf[curitm].fam_type <= idat.fam_type)
27286 || (itemsbuf[curitm].flags & ITEM_KEEPOLD))
27287 {
27288 759 game->set_item(id,true);
27289 759 passiveitem_script(id, doRunPassive);
27290 759 }
27291
27292
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 465 times.
759 if(!(idat.flags & ITEM_KEEPOLD))
27293 {
27294
3/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 114 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
465 if(!get_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.family)<idat.fam_type)
27295 {
27296 114 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.family, idat.fam_type);
27297 114 }
27298 465 }
27299
27300 // NES consistency: replace all flying boomerangs with the current boomerang.
27301
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 21 times.
759 if(idat.family==itype_brang)
27302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 for(int32_t i=0; i<Lwpns.Count(); i++)
27303 {
27304 weapon *w = ((weapon*)Lwpns.spr(i));
27305
27306 if(w->id==wBrang)
27307 {
27308 w->LOADGFX(idat.wpn);
27309 }
27310 21 }
27311 759 }
27312
27313
2/2
✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 6503 times.
7791 if(idat.count!=-1)
27314 {
27315
2/2
✓ Branch 0 taken 6337 times.
✓ Branch 1 taken 166 times.
6503 if(idat.setmax)
27316 {
27317 // Bomb bags are a special case; they may be set not to increase super bombs
27318
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 159 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
166 if(idat.family==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
27319 {
27320 int32_t max = game->get_maxbombs();
27321
27322 if(max<idat.max) max=idat.max;
27323
27324 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
27325 }
27326 else
27327 {
27328 166 int32_t max = game->get_maxcounter(idat.count);
27329
27330
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 141 times.
166 if(max<idat.max) max=idat.max;
27331
27332
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 49 times.
166 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
27333 }
27334 166 }
27335
27336 // Amount is an uint16_t, but the range is -9999 to 16383
27337 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
27338
2/2
✓ Branch 0 taken 191 times.
✓ Branch 1 taken 6312 times.
6503 if(idat.amount&0x3FFF)
27339 {
27340
2/2
✓ Branch 0 taken 4180 times.
✓ Branch 1 taken 2132 times.
6312 if(idat.amount&0x8000)
27341 8360 game->set_dcounter(
27342
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4179 times.
4180 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27343 else
27344 {
27345
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2132 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
27346 game->set_counter(0, idat.count);
27347 else
27348 // This is too confusing to try and change...
27349
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2132 times.
✓ Branch 2 taken 919 times.
✓ Branch 3 taken 1213 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 919 times.
2132 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
27350 }
27351 6312 }
27352 6503 }
27353 }
27354
27355
3/4
✓ Branch 0 taken 7791 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 7575 times.
7791 if(idat.playsound&&!nosound)
27356 {
27357 7575 sfx(idat.playsound);
27358 7575 }
27359
27360 //add lower-level items
27361
2/2
✓ Branch 0 taken 7764 times.
✓ Branch 1 taken 27 times.
7791 if(idat.flags&ITEM_GAINOLD)
27362 {
27363
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 27 times.
50 for(int32_t i=idat.fam_type-1; i>0; i--)
27364 {
27365 23 int32_t potid = getItemID(itemsbuf, idat.family, i);
27366
27367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(potid != -1)
27368 {
27369 23 game->set_item(potid, true);
27370 23 }
27371 23 }
27372 27 }
27373
27374
11/14
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6999 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 315 times.
✓ Branch 6 taken 39 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 41 times.
✓ Branch 9 taken 38 times.
✓ Branch 10 taken 26 times.
✓ Branch 11 taken 274 times.
✓ Branch 12 taken 33 times.
✓ Branch 13 taken 1 times.
7791 switch(idat.family)
27375 {
27376 case itype_itmbundle:
27377 {
27378 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27379 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27380 bool pscript = (idat.flags & ITEM_FLAG1);
27381 for(auto q = 0; q < 10; ++q)
27382 {
27383 if(unsigned(ids[q]) >= MAXITEMS) continue;
27384 if(pscript)
27385 collectitem_script(ids[q]);
27386 getitem(ids[q], true, true);
27387 }
27388 }
27389 break;
27390
27391 case itype_progressive_itm:
27392 {
27393 int32_t newid = get_progressive_item(idat);
27394 if(newid > -1)
27395 getitem(newid, nosound, true);
27396 }
27397 break;
27398
27399 case itype_bottlefill:
27400 {
27401 if(idat.misc1)
27402 {
27403 game->fillBottle(idat.misc1);
27404 }
27405 }
27406 break;
27407
27408 case itype_clock:
27409 {
27410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27411 break;
27412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
315 if((idat.flags & ITEM_FLAG2) && clockclk) //"Can't activate while clock active"
27413 break;
27414 315 setClock(watch=true);
27415
27416
2/2
✓ Branch 0 taken 161280 times.
✓ Branch 1 taken 315 times.
161595 for(int32_t i=0; i<eMAXGUYS; i++)
27417 161280 clock_zoras[i]=0;
27418
27419 315 clockclk=itemsbuf[id&0xFF].misc1;
27420 315 sfx(idat.usesound);
27421 }
27422 315 break;
27423
27424 case itype_lkey:
27425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(game->lvlkeys[dlevel]<255) game->lvlkeys[dlevel]++;
27426 39 break;
27427
27428 case itype_ring:
27429 case itype_magicring:
27430
5/6
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
21 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27431 {
27432 21 ringcolor(false);
27433 21 }
27434 21 break;
27435
27436 case itype_whispring:
27437 {
27438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(idat.flags & ITEM_FLAG1)
27439 {
27440
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
27441
27442
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
27443 4 }
27444
27445
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(idat.power==0)
27446 {
27447 2 setSwordClk(0);
27448 2 setItemClk(0);
27449 2 }
27450
27451 4 break;
27452 }
27453
27454
27455 case itype_map:
27456 41 game->lvlitems[dlevel]|=liMAP;
27457 41 break;
27458
27459 case itype_compass:
27460 38 game->lvlitems[dlevel]|=liCOMPASS;
27461 38 break;
27462
27463 case itype_bosskey:
27464 26 game->lvlitems[dlevel]|=liBOSSKEY;
27465 26 break;
27466
27467 case itype_fairy:
27468
27469
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 182 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 92 times.
274 game->set_life(zc_min(game->get_life()+(idat.flags&ITEM_FLAG1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
27470
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 223 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
274 game->set_magic(zc_min(game->get_magic()+(idat.flags&ITEM_FLAG2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
27471 274 break;
27472
27473 case itype_heartpiece:
27474 33 game->change_HCpieces(1);
27475
27476
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 7 times.
33 if(game->get_HCpieces()<game->get_hcp_per_hc())
27477 26 break;
27478
27479 7 game->set_HCpieces(0);
27480
27481 7 getitem(heart_container_id());
27482 7 break;
27483
27484 case itype_killem:
27485 {
27486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(idat.flags & ITEM_FLAG1) //Active use, not passive
27487 break;
27488 1 kill_em_all();
27489 1 sfx(idat.usesound);
27490 }
27491 1 break;
27492 }
27493
27494 7791 flushItemCache();
27495 7791 update_subscreens();
27496 7791 load_Sitems(&QMisc);
27497 7791 verifyBothWeapons();
27498 7791 }
27499
27500 void takeitem(int32_t id)
27501 {
27502 game->set_item(id, false);
27503 itemdata const& idat = itemsbuf[id];
27504
27505 /* Lower the counters! */
27506 if(idat.count!=-1)
27507 {
27508 if(idat.setmax)
27509 {
27510 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
27511 }
27512
27513 if(idat.amount&0x3FFF)
27514 {
27515 if(idat.amount&0x8000)
27516 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27517 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
27518 }
27519 }
27520
27521 switch(itemsbuf[id&0xFF].family)
27522 {
27523 // NES consistency: replace all flying boomerangs with the current boomerang.
27524 case itype_brang:
27525 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
27526 {
27527 weapon *w = ((weapon*)Lwpns.spr(i));
27528
27529 if(w->id==wBrang)
27530 {
27531 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
27532 }
27533 }
27534
27535 break;
27536
27537 case itype_itmbundle:
27538 {
27539 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
27540 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
27541 for(auto q = 0; q < 10; ++q)
27542 {
27543 if(unsigned(ids[q]) >= MAXITEMS) continue;
27544 takeitem(ids[q]);
27545 }
27546 }
27547 break;
27548
27549 case itype_progressive_itm:
27550 {
27551 int32_t newid = get_progressive_item(idat, true);
27552 if(newid > -1)
27553 takeitem(newid);
27554 }
27555 break;
27556
27557 case itype_heartpiece:
27558 if(game->get_maxlife()>game->get_hp_per_heart())
27559 {
27560 if(game->get_HCpieces()==0)
27561 {
27562 game->set_HCpieces(game->get_hcp_per_hc());
27563 takeitem(iHeartC);
27564 }
27565
27566 game->change_HCpieces(-1);
27567 }
27568 break;
27569
27570 case itype_map:
27571 game->lvlitems[dlevel]&=~liMAP;
27572 break;
27573
27574 case itype_compass:
27575 game->lvlitems[dlevel]&=~liCOMPASS;
27576 break;
27577
27578 case itype_bosskey:
27579 game->lvlitems[dlevel]&=~liBOSSKEY;
27580 break;
27581
27582 case itype_lkey:
27583 if(game->lvlkeys[dlevel]) game->lvlkeys[dlevel]--;
27584 break;
27585
27586 case itype_ring:
27587 if((get_bit(quest_rules,qr_OVERWORLDTUNIC) != 0) || (currscr<128 || dlevel))
27588 {
27589 ringcolor(false);
27590 }
27591 break;
27592 }
27593 }
27594
27595 5610 void post_item_collect()
27596 {
27597 5610 std::vector<int32_t> &ev = FFCore.eventData;
27598 5610 ev.clear();
27599
27600 5610 throwGenScriptEvent(GENSCR_EVENT_POST_COLLECT_ITEM);
27601 5610 }
27602
27603 // Attempt to pick up an item. (-1 = check items touching Hero.)
27604 5147092 void HeroClass::checkitems(int32_t index)
27605 {
27606 5147092 int32_t tmp=currscr>=128?1:0;
27607
27608
2/2
✓ Branch 0 taken 1273 times.
✓ Branch 1 taken 5145819 times.
5147092 if(index==-1)
27609 {
27610
2/2
✓ Branch 0 taken 1044247 times.
✓ Branch 1 taken 5145819 times.
6190066 for(auto ind = items.Count()-1; ind >= 0; --ind)
27611 {
27612 1044247 item* itm = (item*)items.spr(ind);
27613
2/2
✓ Branch 0 taken 1044235 times.
✓ Branch 1 taken 12 times.
1044247 if(itm->get_forcegrab())
27614 {
27615 12 checkitems(ind);
27616 12 }
27617 1044247 }
27618
2/2
✓ Branch 0 taken 657799 times.
✓ Branch 1 taken 4488020 times.
5145819 if(diagonalMovement)
27619 {
27620 657799 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
27621 657799 }
27622 4488020 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
27623 5145819 }
27624
27625
2/2
✓ Branch 0 taken 38763 times.
✓ Branch 1 taken 5108329 times.
5147092 if(index==-1)
27626 5108329 return;
27627
27628 // if (tmpscr[tmp].room==rSHOP && boughtsomething==true)
27629 // return;
27630 38763 item* ptr = (item*)items.spr(index);
27631 38763 int32_t pickup = ptr->pickup;
27632 38763 int8_t exstate = ptr->pickupexstate;
27633 38763 int32_t PriceIndex = ptr->PriceIndex;
27634 38763 int32_t id2 = ptr->id;
27635 38763 int32_t holdid = ptr->id;
27636 38763 int32_t pstr = ptr->pstring;
27637 38763 int32_t pstr_flags = ptr->pickup_string_flags;
27638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38763 times.
38763 if(ptr->fallclk > 0) return; //Don't pick up a falling item
27639
27640
1/2
✓ Branch 0 taken 38763 times.
✗ Branch 1 not taken.
38763 if(itemsbuf[id2].family == itype_progressive_itm)
27641 {
27642 int32_t newid = get_progressive_item(itemsbuf[id2]);
27643 if(newid > -1)
27644 {
27645 id2 = newid;
27646 holdid = newid;
27647 pstr = itemsbuf[newid].pstring;
27648 pstr_flags = itemsbuf[newid].pickup_string_flags;
27649 }
27650 }
27651
27652
2/2
✓ Branch 0 taken 38018 times.
✓ Branch 1 taken 745 times.
38763 bool bottledummy = (pickup&ipCHECK) && tmpscr[tmp].room == rBOTTLESHOP;
27653
27654
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 38761 times.
38763 if(bottledummy) //Dummy bullshit!
27655 {
27656
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!game->canFillBottle())
27657 return;
27658
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27659 {
27660 if(!current_item_power(itype_wallet))
27661 {
27662 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27663 int32_t tmpprice = -abs(prices[PriceIndex]);
27664 //game->change_drupy(-abs(prices[priceindex]));
27665 int32_t total = game->get_drupy()-tmpprice;
27666 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27667 game->set_drupy(game->get_drupy()-total);
27668 }
27669 else //infinite wallet
27670 {
27671 game->change_drupy(0);
27672 }
27673 }
27674 2 boughtsomething=true;
27675 //make the other shop items untouchable after
27676 //you buy something
27677 2 int32_t count = 0;
27678
27679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<3; i++)
27680 {
27681 if(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[i] != 0)
27682 {
27683 ++count;
27684 }
27685 }
27686
27687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for(int32_t i=0; i<items.Count(); i++)
27688 {
27689 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27690 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27691 }
27692
27693 2 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[tmpscr[tmp].catchall].fill[PriceIndex]);
27694 2 id2 = find_bottle_for_slot(slot);
27695 2 ptr->id = id2;
27696 2 pstr = 0;
27697 2 pickup |= ipHOLDUP;
27698 2 }
27699 else
27700 {
27701 38761 std::vector<int32_t> &ev = FFCore.eventData;
27702 38761 ev.clear();
27703 38761 ev.push_back(id2*10000);
27704 38761 ev.push_back(pickup*10000);
27705 38761 ev.push_back(pstr*10000);
27706 38761 ev.push_back(pstr_flags*10000);
27707 38761 ev.push_back(0);
27708 38761 ev.push_back(ptr->getUID());
27709 38761 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
27710 38761 ev.push_back(0);
27711
27712 38761 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
27713 38761 bool nullify = ev[4] != 0;
27714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38761 times.
38761 if(nullify) return;
27715 38761 id2 = ev[0]/10000;
27716 38761 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
27717 38761 pstr = ev[2] / 10000;
27718 38761 pstr_flags = ev[3] / 10000;
27719
27720
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38761 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38761 if(itemsbuf[id2].family == itype_bottlefill && !game->canFillBottle())
27721 return; //No picking these up unless you have a bottle to fill!
27722
27723
5/6
✓ Branch 0 taken 36816 times.
✓ Branch 1 taken 1945 times.
✓ Branch 2 taken 32178 times.
✓ Branch 3 taken 4638 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32178 times.
38761 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
27724
2/2
✓ Branch 0 taken 32090 times.
✓ Branch 1 taken 88 times.
32178 if(ptr->id!=iFairyMoving)
27725 // wait for it to stop flashing, doesn't check for other items yet
27726 32090 return;
27727
27728
2/2
✓ Branch 0 taken 6651 times.
✓ Branch 1 taken 20 times.
6671 if(pickup&ipENEMY) // item was being carried by enemy
27729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
40 if(more_carried_items()<=1) // 1 includes this own item.
27730 20 hasitem &= ~2;
27731
27732
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 6280 times.
6671 if(pickup&ipDUMMY) // dummy item (usually a rupee)
27733 {
27734
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 27 times.
391 if(pickup&ipMONEY)
27735 27 dospecialmoney(index);
27736
27737 391 return;
27738 }
27739
27740
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6280 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6280 if(get_bit(quest_rules,qr_HEARTSREQUIREDFIX) && !canget(id2))
27741 return;
27742
27743 6280 int32_t nextitem = -1;
27744 6280 do
27745 {
27746 6280 nextitem = -1;
27747
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 6266 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 10 times.
6280 if((itemsbuf[id2].flags & ITEM_COMBINE) && game->get_item(id2))
27748 // Item upgrade routine.
27749 {
27750
27751
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t i=0; i<MAXITEMS; i++)
27752 {
27753 // Find the item which is as close to this item's fam_type as possible.
27754
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 2538 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 10 times.
2560 if(itemsbuf[i].family==itemsbuf[id2].family && itemsbuf[i].fam_type>itemsbuf[id2].fam_type
27755
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
22 && (nextitem>-1 ? itemsbuf[i].fam_type<=itemsbuf[nextitem].fam_type : true))
27756 {
27757 10 nextitem = i;
27758 10 }
27759 2560 }
27760
27761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nextitem>-1)
27762 {
27763 10 id2 = nextitem;
27764
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(get_bit(quest_rules,qr_ITEMCOMBINE_NEW_PSTR))
27765 {
27766 pstr = itemsbuf[id2].pstring;
27767 pstr_flags = itemsbuf[id2].pickup_string_flags;
27768 }
27769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(!get_bit(quest_rules,qr_ITEMCOMBINE_CONTINUOUS))
27770 10 break; //no looping
27771 }
27772 }
27773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6270 times.
6270 } while(nextitem > -1);
27774
27775
2/2
✓ Branch 0 taken 5535 times.
✓ Branch 1 taken 745 times.
6280 if(pickup&ipCHECK) // check restrictions
27776
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 568 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 106 times.
745 switch(tmpscr[tmp].room)
27777 {
27778 case rSP_ITEM: // special item
27779
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1 times.
71 if(!canget(id2)) // These ones always need the Hearts Required check
27780 1 return;
27781
27782 70 break;
27783
27784 case rP_SHOP: // potion shop
27785
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 13 times.
106 if(msg_active)
27786 93 return;
27787 [[fallthrough]];
27788 case rSHOP: // shop
27789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 581 times.
581 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
27790 {
27791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 581 times.
581 if(!current_item_power(itype_wallet))
27792 {
27793
2/2
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 52 times.
581 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
27794 52 int32_t tmpprice = -abs(prices[PriceIndex]);
27795 //game->change_drupy(-abs(prices[priceindex]));
27796 52 int32_t total = game->get_drupy()-tmpprice;
27797 52 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
27798 52 game->set_drupy(game->get_drupy()-total);
27799 52 }
27800 else //infinite wallet
27801 {
27802 game->change_drupy(0);
27803 }
27804 52 }
27805 52 boughtsomething=true;
27806 //make the other shop items untouchable after
27807 //you buy something
27808 52 int32_t count = 0;
27809
27810
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t i=0; i<3; i++)
27811 {
27812
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 147 times.
156 if(QMisc.shop[tmpscr[tmp].catchall].hasitem[i] != 0)
27813 {
27814 147 ++count;
27815 147 }
27816 156 }
27817
27818
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 52 times.
251 for(int32_t i=0; i<items.Count(); i++)
27819 {
27820
4/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 95 times.
199 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
27821 95 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
27822 199 }
27823
27824 52 break;
27825 122 }
27826
27827
2/2
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 5086 times.
5657 if(pickup&ipONETIME) // set mITEM for one-time-only items
27828 {
27829 571 setmapflag(mITEM);
27830
27831 //Okay so having old source files is a godsend. You wanna know why?
27832 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
27833 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
27834 //The default would be mITEM if currscr was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
27835 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
27836 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
27837
27838 /*
27839 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
27840 // broken behavior from early ZC versions. If you change things here please comment on it's purpose.
27841
27842 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
27843 // What is etc?! We need to check for every valid state here. ~Gleeok
27844 if(get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW))
27845 {
27846 // Most older quests need one-time-pickups to not remove special items, etc.
27847 if(tmpscr->room==rGRUMBLE)
27848 {
27849 setmapflag(mSPECIALITEM);
27850 }
27851 }
27852 */
27853 571 }
27854
2/2
✓ Branch 0 taken 4863 times.
✓ Branch 1 taken 223 times.
5086 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
27855
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 55 times.
223 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
27856
27857
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
5657 if(exstate > -1 && exstate < 32)
27858 {
27859 1 setxmapflag(1<<exstate);
27860 1 }
27861
27862
2/2
✓ Branch 0 taken 5656 times.
✓ Branch 1 taken 1 times.
5657 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
27863 {
27864
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(tmpscr->flags9&fITEMSECRETPERM) setmapflag(mSECRET);
27865 1 hidden_entrance(0, true, false, -5);
27866 1 }
27867
27868 5657 collectitem_script(id2);
27869 5657 getitem(id2, false, true);
27870 }
27871
27872
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 5216 times.
5659 if(pickup&ipHOLDUP)
27873 {
27874 439 attackclk=0;
27875 439 reset_swordcharge();
27876
27877
3/4
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 435 times.
439 if(action!=swimming && !IsSideSwim())
27878 435 reset_hookshot();
27879
27880
2/2
✓ Branch 0 taken 311 times.
✓ Branch 1 taken 128 times.
439 if(msg_onscreen)
27881 {
27882 128 dismissmsg();
27883 128 }
27884
27885 439 clear_bitmap(pricesdisplaybuf);
27886
27887
6/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 438 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
440 if(get_bit(quest_rules, qr_OLDPICKUP) || ((tmpscr[tmp].room==rSP_ITEM || tmpscr[tmp].room==rRP_HC || tmpscr[tmp].room==rTAKEONE) && (pickup&ipONETIME2)) ||
27888
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 (get_bit(quest_rules, qr_SHOP_ITEMS_VANISH) && (tmpscr[tmp].room==rBOTTLESHOP || tmpscr[tmp].room==rSHOP) && (pickup&ipCHECK)))
27889 {
27890 440 fadeclk=66;
27891 440 }
27892
27893
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 439 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
441 if(id2!=iBombs || action==swimming || get_bit(quest_rules,qr_BOMBHOLDFIX))
27894 {
27895 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
27896
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 433 times.
439 if(action==swimming)
27897 {
27898 6 action=waterhold1; FFCore.setHeroAction(waterhold1);
27899 6 }
27900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 else if(IsSideSwim())
27901 {
27902 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
27903 }
27904 else
27905 {
27906 433 action=landhold1; FFCore.setHeroAction(landhold1);
27907 }
27908
27909
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 140 times.
439 if(ptr->twohand)
27910 {
27911
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 139 times.
140 if(action==waterhold1)
27912 {
27913 1 action=waterhold2; FFCore.setHeroAction(waterhold2);
27914 1 }
27915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 else if(action==sidewaterhold1)
27916 {
27917 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
27918 }
27919 else
27920 {
27921 139 action=landhold2; FFCore.setHeroAction(landhold2);
27922 }
27923 140 }
27924
27925 439 holdclk=130;
27926
27927 //restart music
27928
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 77 times.
439 if(get_bit(quest_rules, qr_HOLDNOSTOPMUSIC) == 0)
27929 77 music_stop();
27930
27931 439 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
27932 439 freeze_guys=true;
27933 //show the info string
27934
27935
27936 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
27937
27938 439 int32_t shop_pstr = 0;
27939
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 63 times.
439 if (PriceIndex > -1)
27940 {
27941
2/3
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
63 switch(tmpscr[tmp].room)
27942 {
27943 case rSHOP:
27944 39 shop_pstr = QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex];
27945 39 break;
27946 case rBOTTLESHOP:
27947 shop_pstr = QMisc.bottle_shop_types[tmpscr[tmp].catchall].str[PriceIndex];
27948 break;
27949 }
27950 63 }
27951
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 439 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 439 times.
439 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
27952 {
27953 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
27954 {
27955 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
27956 }
27957 else pstr = 0;
27958 if(shop_pstr)
27959 {
27960 donewmsg(shop_pstr);
27961 enqueued_str = pstr;
27962 }
27963 else if(pstr)
27964 {
27965 donewmsg(pstr);
27966 }
27967 }
27968
27969 439 }
27970
27971
3/4
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 398 times.
✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
441 if(itemsbuf[id2].family!=itype_triforcepiece || !(itemsbuf[id2].flags & ITEM_GAMEDATA))
27972 {
27973 398 sfx(tmpscr[0].holdupsfx);
27974 398 }
27975
27976 441 ptr->set_forcegrab(false);
27977 441 items.del(index);
27978
27979
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 441 times.
560 for(int32_t i=0; i<Lwpns.Count(); i++)
27980 {
27981 119 weapon *w = (weapon*)Lwpns.spr(i);
27982
27983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if(w->dragging==index)
27984 {
27985 w->dragging=-1;
27986 }
27987
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 else if(w->dragging>index)
27988 {
27989 w->dragging-=1;
27990 }
27991 119 }
27992
27993 // clear up shop stuff
27994
4/4
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 157 times.
✓ Branch 3 taken 62 times.
441 if((isdungeon()==0)&&(index!=0))
27995 {
27996
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 48 times.
62 if(boughtsomething)
27997 {
27998 48 fadeclk=66;
27999
28000
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
48 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
28001 {
28002 48 items.del(0);
28003
28004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 for(int32_t i=0; i<Lwpns.Count(); i++)
28005 {
28006 weapon *w = (weapon*)Lwpns.spr(i);
28007
28008 if(w->dragging==0)
28009 {
28010 w->dragging=-1;
28011 }
28012 else if(w->dragging>0)
28013 {
28014 w->dragging-=1;
28015 }
28016 }
28017 48 }
28018 48 }
28019
28020
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(msg_onscreen)
28021 {
28022 dismissmsg();
28023 }
28024
28025 62 clear_bitmap(pricesdisplaybuf);
28026 62 set_clip_state(pricesdisplaybuf, 1);
28027 62 }
28028
28029 // items.del(index);
28030 441 }
28031 else
28032 {
28033 5216 ptr->set_forcegrab(false);
28034 5216 items.del(index);
28035
28036
2/2
✓ Branch 0 taken 4820 times.
✓ Branch 1 taken 5216 times.
10036 for(int32_t i=0; i<Lwpns.Count(); i++)
28037 {
28038 4820 weapon *w = (weapon*)Lwpns.spr(i);
28039
28040
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 4783 times.
4820 if(w->dragging==index)
28041 {
28042 37 w->dragging=-1;
28043 37 }
28044
1/2
✓ Branch 0 taken 4783 times.
✗ Branch 1 not taken.
4783 else if(w->dragging>index)
28045 {
28046 w->dragging-=1;
28047 }
28048 4820 }
28049
28050
2/2
✓ Branch 0 taken 5215 times.
✓ Branch 1 taken 1 times.
5216 if(msg_onscreen)
28051 {
28052 1 dismissmsg();
28053 1 }
28054
28055 //general item pickup message
28056 //show the info string
28057 //non-held
28058 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
28059
3/6
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 5118 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5216 int32_t shop_pstr = ( tmpscr[tmp].room == rSHOP && PriceIndex>=0 && QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] > 0 ) ? QMisc.shop[tmpscr[tmp].catchall].str[PriceIndex] : 0;
28060
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5215 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5215 times.
5216 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
28061 {
28062
6/12
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
1 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
28063 {
28064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
28065 1 }
28066 else pstr = 0;
28067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(shop_pstr)
28068 {
28069 donewmsg(shop_pstr);
28070 enqueued_str = pstr;
28071 }
28072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(pstr)
28073 {
28074 1 donewmsg(pstr);
28075 1 }
28076 1 }
28077
28078
28079 5216 clear_bitmap(pricesdisplaybuf);
28080 5216 set_clip_state(pricesdisplaybuf, 1);
28081 }
28082
28083
2/2
✓ Branch 0 taken 5608 times.
✓ Branch 1 taken 49 times.
5657 if(itemsbuf[id2].family==itype_triforcepiece)
28084 {
28085
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 6 times.
49 if(itemsbuf[id2].misc2>0) //Small TF Piece
28086 {
28087 43 getTriforce(id2);
28088 43 }
28089 else
28090 {
28091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (ptr->linked_parent == eeGANON) game->lvlitems[dlevel]|=liBOSS;
28092 6 getBigTri(id2);
28093 }
28094 49 }
28095
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 5261 times.
5657 if(!holdclk)
28096 5261 post_item_collect();
28097 5147090 }
28098
28099 158 void HeroClass::StartRefill(int32_t refillWhat)
28100 {
28101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 if(!refilling)
28102 {
28103 158 refillclk=21;
28104 158 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
28105 158 sfx(WAV_REFILL,128,true);
28106 158 refilling=refillWhat;
28107
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 6 times.
158 if(FFCore.quest_format[vZelda] < 0x255)
28108 {
28109 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
28110 //I attempted to change this check to a quest rule, but here's the issue: this affects
28111 //triforces and potions as well, not just fairy flags. This means that having a compat rule
28112 //would result in a rule that is checked by default for every tileset or quest made before
28113 //2.55, one in a place most people won't check. That means that if they were to go to use
28114 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
28115 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
28116 //"go through the compat rules and turn them all off", so this remains a version check instead
28117 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
28118 152 Start250Refill(refillWhat);
28119 152 }
28120 else //use 2.55+ behavior
28121 {
28122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(refill_why>=0) // Item index
28123 {
28124 if(itemsbuf[refill_why].family==itype_potion)
28125 {
28126 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
28127 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
28128 }
28129 else if(itemsbuf[refill_why].family==itype_triforcepiece)
28130 {
28131 if(itemsbuf[refill_why].flags & ITEM_FLAG3){swordclk=0;verifyAWpn();}
28132 if(itemsbuf[refill_why].flags & ITEM_FLAG4)itemclk=0;
28133 }
28134 }
28135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(refill_why==REFILL_FAIRY)
28136 {
28137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
28138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_bit(quest_rules,qr_ITEMBUBBLE))itemclk=0;
28139 6 }
28140 }
28141 158 }
28142 158 }
28143
28144 152 void HeroClass::Start250Refill(int32_t refillWhat)
28145 {
28146
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 if(!refilling)
28147 {
28148 refillclk=21;
28149 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
28150 sfx(WAV_REFILL,128,true);
28151 refilling=refillWhat;
28152
28153 if(refill_why>=0) // Item index
28154 {
28155 if((itemsbuf[refill_why].family==itype_potion)&&(!get_bit(quest_rules,qr_NONBUBBLEMEDICINE)))
28156 {
28157 swordclk=0;
28158 verifyAWpn();
28159 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
28160 }
28161
28162 if((itemsbuf[refill_why].family==itype_triforcepiece)&&(!get_bit(quest_rules,qr_NONBUBBLETRIFORCE)))
28163 {
28164 swordclk=0;
28165 verifyAWpn();
28166 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
28167 }
28168 }
28169 else if((refill_why==REFILL_FAIRY)&&(!get_bit(quest_rules,qr_NONBUBBLEFAIRIES)))
28170 {
28171 swordclk=0;
28172 verifyAWpn();
28173 if(get_bit(quest_rules,qr_ITEMBUBBLE)) itemclk=0;
28174 }
28175 }
28176 152 }
28177
28178 199440 bool HeroClass::refill()
28179 {
28180
4/4
✓ Branch 0 taken 15616 times.
✓ Branch 1 taken 183824 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 14980 times.
199440 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
28181 {
28182 184460 return false;
28183 }
28184
28185 14980 ++refillclk;
28186 14980 int32_t speed = get_bit(quest_rules,qr_FASTFILL) ? 6 : 22;
28187 14980 int32_t refill_heart_stop=game->get_maxlife();
28188 14980 int32_t refill_magic_stop=game->get_maxmagic();
28189
28190
4/4
✓ Branch 0 taken 7396 times.
✓ Branch 1 taken 7584 times.
✓ Branch 2 taken 2441 times.
✓ Branch 3 taken 4955 times.
14980 if(refill_why>=0 && itemsbuf[refill_why].family==itype_potion)
28191 {
28192
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & ITEM_FLAG1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
28193
2/6
✓ Branch 0 taken 4955 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4955 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4955 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & ITEM_FLAG2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
28194 4955 }
28195
28196
2/2
✓ Branch 0 taken 13530 times.
✓ Branch 1 taken 1450 times.
14980 if(refillclk%speed == 0)
28197 {
28198 // game->life&=0xFFC;
28199
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 757 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 693 times.
1450 switch(refill_what)
28200 {
28201 case REFILL_LIFE:
28202
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 720 times.
757 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28203
28204
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 665 times.
757 if(game->get_life()>=refill_heart_stop)
28205 {
28206 92 game->set_life(refill_heart_stop);
28207 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28208
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 92 times.
23644 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28209 {
28210
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23460 times.
23552 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28211
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 23459 times.
23460 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28212 23459 stop_sfx(q);
28213 23459 }
28214 92 sfx(QMisc.miscsfx[sfxREFILL]);
28215 92 refilling=REFILL_NONE;
28216 92 return false;
28217 }
28218
28219 665 break;
28220
28221 case REFILL_MAGIC:
28222 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28223
28224 if(game->get_magic()>=refill_magic_stop)
28225 {
28226 game->set_magic(refill_magic_stop);
28227 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28228 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28229 {
28230 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28231 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28232 stop_sfx(q);
28233 }
28234 sfx(QMisc.miscsfx[sfxREFILL]);
28235 refilling=REFILL_NONE;
28236 return false;
28237 }
28238
28239 break;
28240
28241 case REFILL_ALL:
28242
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 633 times.
693 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
28243
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 30 times.
693 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
28244
28245
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 608 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 19 times.
693 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
28246 {
28247 66 game->set_life(refill_heart_stop);
28248 66 game->set_magic(refill_magic_stop);
28249 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
28250
2/2
✓ Branch 0 taken 16896 times.
✓ Branch 1 taken 66 times.
16962 for ( int32_t q = 0; q < WAV_COUNT; q++ )
28251 {
28252
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 16830 times.
16896 if ( q == (int32_t)tmpscr->oceansfx ) continue;
28253
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 16811 times.
16830 if ( q == (int32_t)tmpscr->bosssfx ) continue;
28254 16811 stop_sfx(q);
28255 16811 }
28256 66 sfx(QMisc.miscsfx[sfxREFILL]);
28257 66 refilling=REFILL_NONE;
28258 66 return false;
28259 }
28260
28261 627 break;
28262 }
28263 1292 }
28264
28265 14822 return true;
28266 199440 }
28267
28268 43 void HeroClass::getTriforce(int32_t id2)
28269 {
28270
28271 PALETTE flash_pal;
28272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
28273
28274
2/2
✓ Branch 0 taken 11008 times.
✓ Branch 1 taken 43 times.
11051 for(int32_t i=0; i<256; i++)
28275 {
28276
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 7168 times.
11008 flash_pal[i] = get_bit(quest_rules,qr_FADE) ? _RGB(63,63,0) : _RGB(63,63,63);
28277 11008 }
28278
28279
28280
28281 //get rid off all sprites but Hero
28282 43 guys.clear();
28283 43 items.clear();
28284 43 Ewpns.clear();
28285 43 Lwpns.clear();
28286 43 Sitems.clear();
28287 43 chainlinks.clear();
28288
28289 //decorations.clear();
28290
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 17 times.
43 if(!COOLSCROLL)
28291 {
28292 17 show_subscreen_items=false;
28293 17 }
28294
28295 43 sfx(itemsbuf[id2].playsound);
28296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) music_stop();
28297
28298 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
28299
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if ( (itemsbuf[id2].flags & ITEM_FLAG14) )
28300 {
28301 uint8_t playwav = itemsbuf[id2].misc3;
28302 //zprint2("playwav is: %d\n", playwav);
28303 sfx(playwav);
28304
28305 }
28306
28307 //itemsbuf[id2].flags & ITEM_FLAG9 : Don't dismiss Messages
28308 //itemsbuf[id2].flags & ITEM_FLAG10 : Cutscene interrupts action script..
28309 //itemsbuf[id2].flags & ITEM_FLAG11 : Don't change music.
28310 //itemsbuf[id2].flags & ITEM_FLAG12 : Run Collect Script Script On Collection
28311 //itemsbuf[id2].flags & ITEM_FLAG13 : Run Action Script On Collection
28312 //itemsbuf[id2].flags & ITEM_FLAG14 : Play second sound (WAV) from Attributes[2] (misc2)
28313 //itemsbuf[id2].flags & ITEM_FLAG15 : No MIDI
28314
28315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(!(itemsbuf[id2].flags & ITEM_FLAG15)) //No MIDI flag
28316 {
28317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(itemsbuf[id2].misc1)
28318 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
28319 else
28320 43 try_zcmusic((char*)moduledata.base_NSF_file,moduledata.tf_track, ZC_MIDI_TRIFORCE);
28321 43 }
28322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28323 {
28324 43 game->lvlitems[dlevel]|=liTRIFORCE;
28325 43 }
28326
28327 43 int32_t f=0;
28328 43 int32_t x2=0;
28329 43 int32_t curtain_x=0;
28330 43 int32_t c=0;
28331 /*if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //Run collect script This happens w/o the flag.
28332 {
28333 if(itemsbuf[id2].collect_script && !item_collect_doscript[id2])
28334 {
28335 //clear the item script stack for a new script
28336 ri = &(itemCollectScriptData[id2]);
28337 for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[id2][q] = 0xFFFF;
28338 ri->Clear();
28339 //itemCollectScriptData[(id2 & 0xFFF)].Clear();
28340 //for ( int32_t q = 0; q < 1024; q++ ) item_collect_stack[(id2 & 0xFFF)][q] = 0;
28341 //ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2 & 0xFFF)*-1));
28342 if ( id2 > 0 && !item_collect_doscript[id2] ) //No collect script on item 0.
28343 {
28344 item_collect_doscript[id2] = 1;
28345 itemscriptInitialised[id2] = 0;
28346 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, ((id2)*-1));
28347 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28348 FFCore.deallocateAllArrays(SCRIPT_ITEM,-(id2));
28349 }
28350 else if (!id2 && !item_collect_doscript[id2]) //item 0
28351 {
28352 item_collect_doscript[id2] = 1;
28353 itemscriptInitialised[id2] = 0;
28354 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].collect_script, COLLECT_SCRIPT_ITEM_ZERO);
28355 //if ( !get_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING) )
28356 FFCore.deallocateAllArrays(SCRIPT_ITEM,COLLECT_SCRIPT_ITEM_ZERO);
28357 }
28358 }
28359 }
28360 */
28361 43 do
28362 {
28363
28364
28365
1/2
✓ Branch 0 taken 23003 times.
✗ Branch 1 not taken.
23003 if ( (itemsbuf[id2].flags & ITEM_FLAG13) ) //Run action script on collection.
28366 {
28367 if ( itemsbuf[id2].script )
28368 {
28369 if ( !item_doscript[id2] )
28370 {
28371 ri = &(itemScriptData[id2]);
28372 for ( int32_t q = 0; q < 1024; q++ ) item_stack[id2][q] = 0xFFFF;
28373 ri->Clear();
28374 item_doscript[id2] = 1;
28375 itemscriptInitialised[id2] = 0;
28376 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2);
28377 FFCore.deallocateAllArrays(SCRIPT_ITEM,(id2));
28378 }
28379 else
28380 {
28381 if ( !(itemsbuf[id2].flags & ITEM_FLAG10) ) //Cutscene halts the script it resumes after cutscene.
28382 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
28383 }
28384 }
28385 }
28386 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
28387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23003 times.
23003 if ( (itemsbuf[id2].flags & ITEM_FLAG12) ) //No cutscene
28388 {
28389 return;
28390 }
28391
2/2
✓ Branch 0 taken 22960 times.
✓ Branch 1 taken 43 times.
23003 if(f==40)
28392 {
28393 43 actiontype oldaction = action;
28394 43 ALLOFF((!(itemsbuf[id2].flags & ITEM_FLAG9)), false);
28395 43 action=oldaction; // have to reset this flag
28396 43 FFCore.setHeroAction(oldaction);
28397 43 }
28398
28399
28400
4/4
✓ Branch 0 taken 21283 times.
✓ Branch 1 taken 1720 times.
✓ Branch 2 taken 19219 times.
✓ Branch 3 taken 2064 times.
23003 if(f>=40 && f<88)
28401 {
28402
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 1344 times.
2064 if(get_bit(quest_rules,qr_FADE))
28403 {
28404
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
720 if (!flash_reduction_enabled() && (f&7) == 0)
28405 {
28406 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
28407 refreshpal=true;
28408 }
28409
28410
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 180 times.
720 if((f&3)==2)
28411 {
28412 180 loadpalset(0,0);
28413 180 loadpalset(1,1);
28414 180 loadpalset(5,5);
28415
28416
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 12 times.
180 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28417 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
28418 180 }
28419 720 }
28420 else
28421 {
28422
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1344 if(!flash_reduction_enabled() && (f&7) == 0)
28423 {
28424 for(int32_t cs2=2; cs2<5; cs2++)
28425 {
28426 for(int32_t i=1; i<16; i++)
28427 {
28428 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
28429 }
28430 }
28431
28432 refreshpal=true;
28433 }
28434
28435
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==4)
28436 {
28437
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
28438 else loadlvlpal(0xB);
28439
28440 168 loadpalset(5,5);
28441 168 }
28442 }
28443 2064 }
28444
28445
28446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23003 times.
23003 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
28447 {
28448
2/2
✓ Branch 0 taken 22960 times.
✓ Branch 1 taken 43 times.
23003 if(f==refill_frame)
28449 {
28450 43 refill_what=REFILL_ALL;
28451 43 refill_why=id2;
28452 43 StartRefill(REFILL_ALL);
28453 43 refill();
28454 43 }
28455
28456
2/2
✓ Branch 0 taken 20597 times.
✓ Branch 1 taken 2406 times.
23003 if(f==(refill_frame+1))
28457 {
28458
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 2363 times.
2406 if(refill())
28459 {
28460 2363 --f;
28461 2363 }
28462 2406 }
28463 23003 }
28464
28465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23003 times.
23003 if(itemsbuf[id2].flags & ITEM_FLAG1) // Warp out flag
28466 {
28467
4/4
✓ Branch 0 taken 11696 times.
✓ Branch 1 taken 11307 times.
✓ Branch 2 taken 8256 times.
✓ Branch 3 taken 3440 times.
23003 if(f>=208 && f<288)
28468 {
28469 3440 ++x2;
28470
28471
3/3
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 1376 times.
✓ Branch 2 taken 688 times.
3440 switch(++c)
28472 {
28473 case 5:
28474 688 c=0;
28475 [[fallthrough]];
28476 case 0:
28477 case 2:
28478 case 3:
28479 2064 ++x2;
28480 2064 break;
28481 }
28482 3440 }
28483
28484 23003 do_dcounters();
28485
28486
2/2
✓ Branch 0 taken 8256 times.
✓ Branch 1 taken 14747 times.
23003 if(f<288)
28487 {
28488 14747 curtain_x=x2&0xF8;
28489 14747 draw_screen_clip_rect_x1=curtain_x;
28490 14747 draw_screen_clip_rect_x2=255-curtain_x;
28491 14747 draw_screen_clip_rect_y1=0;
28492 14747 draw_screen_clip_rect_y2=223;
28493 //draw_screen(tmpscr);
28494 14747 }
28495 23003 }
28496
28497 23003 draw_screen(tmpscr);
28498 //this causes bugs
28499 //the subscreen appearing over the curtain effect should now be fixed in draw_screen
28500 //so this is not necessary -DD
28501 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,false);
28502
28503 //Run Triforce Script
28504 23003 advanceframe(true);
28505 23003 ++f;
28506
2/2
✓ Branch 0 taken 22960 times.
✓ Branch 1 taken 43 times.
46006 }
28507 while
28508 (
28509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23003 times.
23003 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
28510
4/6
✓ Branch 0 taken 3139 times.
✓ Branch 1 taken 19864 times.
✓ Branch 2 taken 3139 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3139 times.
23003 || (!(itemsbuf[id2].flags & ITEM_FLAG15) /*&& !(itemsbuf[id2].flags & ITEM_FLAG11)*/ && (midi_pos > 0 && !replay_is_active()))
28511
4/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2993 times.
✓ Branch 7 taken 146 times.
6278 || (/*!(itemsbuf[id2].flags & ITEM_FLAG15) &&*/ !(itemsbuf[id2].flags & ITEM_FLAG11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
28512 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
28513 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
28514 // value doesn't matter.
28515
2/4
✓ Branch 0 taken 2993 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3139 times.
3139 || (replay_is_active() && f < 480) )
28516 ); // 800 may not be just right, but it works
28517
28518 43 action=none; FFCore.setHeroAction(none);
28519 43 holdclk=0;
28520 43 draw_screen_clip_rect_x1=0;
28521 43 draw_screen_clip_rect_x2=255;
28522 43 draw_screen_clip_rect_y1=0;
28523 43 draw_screen_clip_rect_y2=223;
28524 43 show_subscreen_items=true;
28525
28526 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
28527 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
28528
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 1 times.
43 if(itemsbuf[id2].flags & ITEM_FLAG1 && ( get_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR) ? ( currscr < MAPSCRS192b136 ) : (currscr < MAPSCRSNORMAL) ) )
28529 {
28530 44 sdir=dir;
28531 44 dowarp(1,0); //side warp
28532 44 }
28533 else
28534 {
28535
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !(itemsbuf[id2].flags & ITEM_FLAG11) ) playLevelMusic();
28536 }
28537 43 }
28538
28539 1554 void red_shift()
28540 {
28541 1554 int32_t tnum=176;
28542
28543 // set up the new palette
28544
2/2
✓ Branch 0 taken 49728 times.
✓ Branch 1 taken 1554 times.
51282 for(int32_t i=CSET(2); i < CSET(4); i++)
28545 {
28546 49728 int32_t r = (i-CSET(2)) << 1;
28547 49728 RAMpal[i+tnum].r = r;
28548 49728 RAMpal[i+tnum].g = r >> 3;
28549 49728 RAMpal[i+tnum].b = r >> 4;
28550 49728 }
28551
28552 // color scale the game screen
28553
2/2
✓ Branch 0 taken 261072 times.
✓ Branch 1 taken 1554 times.
262626 for(int32_t y=0; y<168; y++)
28554 {
28555
2/2
✓ Branch 0 taken 66834432 times.
✓ Branch 1 taken 261072 times.
67095504 for(int32_t x=0; x<256; x++)
28556 {
28557 66834432 int32_t c = framebuf->line[y+playing_field_offset][x];
28558
2/2
✓ Branch 0 taken 58669327 times.
✓ Branch 1 taken 8165105 times.
66834432 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28559
1/2
✓ Branch 0 taken 66834432 times.
✗ Branch 1 not taken.
66834432 framebuf->line[y+playing_field_offset][x] = (c ? (r+tnum+CSET(2)) : 0);
28560 66834432 }
28561 261072 }
28562
28563 1554 refreshpal = true;
28564 1554 }
28565
28566
28567
28568 void setup_red_screen_old()
28569 {
28570 clear_bitmap(framebuf);
28571 rectfill(scrollbuf, 0, 0, 255, 167, 0);
28572
28573 if(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(scrollbuf, 0, 2, tmpscr, 0, playing_field_offset, 2);
28574
28575 if(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(scrollbuf, 0, 3, tmpscr, 0, playing_field_offset, 2);
28576
28577 putscr(scrollbuf, 0, 0, tmpscr);
28578 putscrdoors(scrollbuf,0,0,tmpscr);
28579 blit(scrollbuf, framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28580 do_layer(framebuf, 0, 1, tmpscr, 0, 0, 2);
28581
28582 if(!(XOR(tmpscr->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG))) do_layer(framebuf, 0, 2, tmpscr, 0, 0, 2);
28583
28584 do_layer(framebuf, -2, 0, tmpscr, 0, 0, 2);
28585 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
28586 {
28587 do_layer(framebuf, -2, 1, tmpscr, 0, 0, 2);
28588 do_layer(framebuf, -2, 2, tmpscr, 0, 0, 2);
28589 }
28590
28591 if(!(msg_bg_display_buf->clip))
28592 {
28593 blit_msgstr_bg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28594 }
28595
28596 if(!(msg_portrait_display_buf->clip))
28597 {
28598 blit_msgstr_prt(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28599 }
28600
28601 if(!(msg_txt_display_buf->clip))
28602 {
28603 blit_msgstr_fg(framebuf, 0, 0, 0, playing_field_offset, 256, 168);
28604 }
28605
28606 if(!(pricesdisplaybuf->clip))
28607 {
28608 masked_blit(pricesdisplaybuf, framebuf,0,0,0,playing_field_offset, 256,168);
28609 }
28610
28611 //red shift
28612 // color scale the game screen
28613 for(int32_t y=0; y<168; y++)
28614 {
28615 for(int32_t x=0; x<256; x++)
28616 {
28617 int32_t c = framebuf->line[y+playing_field_offset][x];
28618 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28619 framebuf->line[y+playing_field_offset][x] = (c ? (r+CSET(2)) : 0);
28620 }
28621 }
28622
28623 // Hero->draw(framebuf);
28624 blit(framebuf,scrollbuf, 0, playing_field_offset, 256, playing_field_offset, 256, 168);
28625
28626 clear_bitmap(framebuf);
28627
28628 if(!((tmpscr->layermap[2]==0||(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)))
28629 && tmpscr->layermap[3]==0
28630 && tmpscr->layermap[4]==0
28631 && tmpscr->layermap[5]==0
28632 && !overheadcombos(tmpscr)))
28633 {
28634 if(!(XOR(tmpscr->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG))) do_layer(framebuf, 0, 3, tmpscr, 0, 0, 2);
28635
28636 do_layer(framebuf, 0, 4, tmpscr, 0, 0, 2);
28637 do_layer(framebuf, -1, 0, tmpscr, 0, 0, 2);
28638 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
28639 {
28640 do_layer(framebuf, -1, 1, tmpscr, 0, 0, 2);
28641 do_layer(framebuf, -1, 2, tmpscr, 0, 0, 2);
28642 }
28643 do_layer(framebuf, 0, 5, tmpscr, 0, 0, 2);
28644 do_layer(framebuf, 0, 6, tmpscr, 0, 0, 2);
28645
28646 //do an AND masked blit for messages on top of layers
28647 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(pricesdisplaybuf->clip) || !(msg_portrait_display_buf->clip))
28648 {
28649 BITMAP* subbmp = create_bitmap_ex(8,256,168);
28650 clear_bitmap(subbmp);
28651 if(!(msg_txt_display_buf->clip) || !(msg_bg_display_buf->clip) || !(msg_portrait_display_buf->clip))
28652 {
28653 masked_blit(framebuf, subbmp, 0, playing_field_offset, 0, 0, 256, 168);
28654 if(!(msg_bg_display_buf->clip)) blit_msgstr_bg(subbmp, 0, 0, 0, 0, 256, 168);
28655 if(!(msg_portrait_display_buf->clip)) blit_msgstr_prt(subbmp, 0, 0, 0, 0, 256, 168);
28656 if(!(msg_txt_display_buf->clip)) blit_msgstr_fg(subbmp, 0, 0, 0, 0, 256, 168);
28657 }
28658 for(int32_t y=0; y<168; y++)
28659 {
28660 for(int32_t x=0; x<256; x++)
28661 {
28662 int32_t c1 = framebuf->line[y+playing_field_offset][x];
28663 int32_t c2 = subbmp->line[y][x];
28664 int32_t c3 = pricesdisplaybuf->clip ? 0 : pricesdisplaybuf->line[y][x];
28665
28666 if(c1 && c3)
28667 {
28668 framebuf->line[y+playing_field_offset][x] = c3;
28669 }
28670 else if(c1 && c2)
28671 {
28672 framebuf->line[y+playing_field_offset][x] = c2;
28673 }
28674 }
28675 }
28676 destroy_bitmap(subbmp);
28677 }
28678
28679 //red shift
28680 // color scale the game screen
28681 for(int32_t y=0; y<168; y++)
28682 {
28683 for(int32_t x=0; x<256; x++)
28684 {
28685 int32_t c = framebuf->line[y+playing_field_offset][x];
28686 int32_t r = zc_min(int32_t(RAMpal[c].r*0.4 + RAMpal[c].g*0.6 + RAMpal[c].b*0.4)>>1,31);
28687 framebuf->line[y+playing_field_offset][x] = r+CSET(2);
28688 }
28689 }
28690 }
28691
28692 blit(framebuf,scrollbuf, 0, playing_field_offset, 0, playing_field_offset, 256, 168);
28693
28694 // set up the new palette
28695 for(int32_t i=CSET(2); i < CSET(4); i++)
28696 {
28697 int32_t r = (i-CSET(2)) << 1;
28698 RAMpal[i].r = r;
28699 RAMpal[i].g = r >> 3;
28700 RAMpal[i].b = r >> 4;
28701 }
28702
28703 refreshpal = true;
28704 }
28705
28706
28707
28708 60 void slide_in_color(int32_t color)
28709 {
28710
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 60 times.
360 for(int32_t i=1; i<16; i+=3)
28711 {
28712 300 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
28713 300 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
28714 300 RAMpal[CSET(2)+i] = NESpal(color);
28715 300 }
28716
28717 60 refreshpal=true;
28718 60 }
28719
28720
28721 27 void HeroClass::heroDeathAnimation()
28722 {
28723 27 int32_t f=0;
28724 27 int32_t deathclk=0,deathfrm=0;
28725
28726 27 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
28727
28728 27 kill_sfx(); //call before the onDeath script.
28729
28730 //do
28731 //{
28732
28733 // ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28734 // FFCore.Waitframe();
28735 //}while(player_doscript);
28736 //ZScriptVersion::RunScript(SCRIPT_PLAYER, SCRIPT_PLAYER_DEATH, SCRIPT_PLAYER_DEATH);
28737 //while(player_doscript) { advanceframe(true); } //Not safe. The script runs for only one frame at present.
28738
28739 //Playing=false;
28740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(!debug_enabled)
28741 {
28742 27 Paused=false;
28743 27 }
28744
28745 /*
28746 game->set_deaths(zc_min(game->get_deaths()+1,999));
28747 dir=down;
28748 music_stop();
28749
28750 attackclk=hclk=superman=0;
28751 scriptcoldet = 1;
28752
28753 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28754
28755
28756
28757 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28758 quakeclk=wavy=0;
28759
28760 //in original Z1, Hero marker vanishes at death.
28761 //code in subscr.cpp, put_passive_subscr checks the following value.
28762 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28763 //Also, subscreen is static after death in Z1.
28764 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28765 QMisc.colors.hero_dot = 255;
28766 //doesn't work
28767 //scrollbuf is tampered with by draw_screen()
28768 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28769 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28770 clear_bitmap(subscrbmp);
28771 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, false, sspUP);
28772 QMisc.colors.hero_dot = tmp_hero_dot;
28773 */
28774 27 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
28775 27 clear_bitmap(subscrbmp);
28776 //get rid off all sprites but Hero
28777 27 guys.clear();
28778 27 items.clear();
28779 27 Ewpns.clear();
28780 27 Lwpns.clear();
28781 27 Sitems.clear();
28782 27 chainlinks.clear();
28783 27 decorations.clear();
28784 27 Playing = false;
28785
28786
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
28787 27 dir=down;
28788 27 music_stop();
28789
28790 27 attackclk=hclk=superman=0;
28791 27 scriptcoldet = 1;
28792
28793
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 27 times.
891 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
28794
28795
28796
28797 27 playing_field_offset=56; // otherwise, red_shift() may go past the bottom of the screen
28798 27 quakeclk=wavy=0;
28799
28800 //in original Z1, Hero marker vanishes at death.
28801 //code in subscr.cpp, put_passive_subscr checks the following value.
28802 //color 255 is a GUI color, so quest makers shouldn't be using this value.
28803 //Also, subscreen is static after death in Z1.
28804 27 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
28805 27 QMisc.colors.hero_dot = 255;
28806 //doesn't work
28807 //scrollbuf is tampered with by draw_screen()
28808 //put_passive_subscr(scrollbuf, &QMisc, 256, passive_subscreen_offset, false, false);//save this and reuse it.
28809
28810 27 put_passive_subscr(subscrbmp, &QMisc, 0, passive_subscreen_offset, game->should_show_time(), sspUP);
28811 //Don't forget passive subscreen scripts!
28812
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 1 times.
27 if(get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
28813 {
28814 1 script_drawing_commands.Clear(); //We only want draws from this script
28815
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(DMaps[currdmap].passive_sub_script != 0)
28816 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28817
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(passive_subscreen_waitdraw && DMaps[currdmap].passive_sub_script != 0 && passive_subscreen_doscript != 0)
28818 {
28819 ZScriptVersion::RunScript(SCRIPT_PASSIVESUBSCREEN, DMaps[currdmap].passive_sub_script, currdmap);
28820 passive_subscreen_waitdraw = false;
28821 }
28822 1 BITMAP* tmp = framebuf;
28823 1 framebuf = subscrbmp; //Hack; force draws to subscrbmp
28824 1 do_script_draws(framebuf, tmpscr, 0, playing_field_offset); //Draw the script draws
28825 1 framebuf = tmp;
28826 1 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
28827 1 }
28828 27 QMisc.colors.hero_dot = tmp_hero_dot;
28829 27 bool clearedit = false;
28830 27 do
28831 {
28832
2/2
✓ Branch 0 taken 6654 times.
✓ Branch 1 taken 2574 times.
9228 if(f<254)
28833 {
28834
2/2
✓ Branch 0 taken 5763 times.
✓ Branch 1 taken 891 times.
6654 if(f<=32)
28835 {
28836 891 hclk=(32-f);
28837 891 }
28838
28839
4/4
✓ Branch 0 taken 4992 times.
✓ Branch 1 taken 1662 times.
✓ Branch 2 taken 3016 times.
✓ Branch 3 taken 1976 times.
6654 if(f>=62 && f<138)
28840 {
28841
5/5
✓ Branch 0 taken 1560 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 104 times.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 104 times.
1976 switch((f-62)%20)
28842 {
28843 case 0:
28844 104 dir=right;
28845 104 break;
28846
28847 case 5:
28848 104 dir=up;
28849 104 break;
28850
28851 case 10:
28852 104 dir=left;
28853 104 break;
28854
28855 case 15:
28856 104 dir=down;
28857 104 break;
28858 }
28859
28860 1976 herostep();
28861 1976 }
28862
28863
4/4
✓ Branch 0 taken 1560 times.
✓ Branch 1 taken 5094 times.
✓ Branch 2 taken 1196 times.
✓ Branch 3 taken 364 times.
6654 if(f>=194 && f<208)
28864 {
28865
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 26 times.
364 if(f==194)
28866 {
28867 26 action=dying;
28868 26 FFCore.setHeroAction(dying);
28869 26 }
28870
28871 364 extend = 0;
28872 364 cs = wpnsbuf[spr_death].csets&15;
28873 364 tile = wpnsbuf[spr_death].tile;
28874
1/2
✓ Branch 0 taken 364 times.
✗ Branch 1 not taken.
364 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
28875 {
28876 tile += deathfrm;
28877 f = 206;
28878 if(++deathclk >= wpnsbuf[spr_death].speed)
28879 {
28880 deathclk=0;
28881 if(++deathfrm >= wpnsbuf[spr_death].frames)
28882 {
28883 f = 208;
28884 deathfrm = 0;
28885 }
28886 }
28887 }
28888
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 224 times.
364 else if(BSZ)
28889 {
28890 140 tile += (f-194)/3;
28891 140 }
28892
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 64 times.
224 else if(f>=204)
28893 {
28894 64 ++tile;
28895 64 }
28896 364 }
28897
28898
2/2
✓ Branch 0 taken 6628 times.
✓ Branch 1 taken 26 times.
6654 if(f==208)
28899 {
28900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 if ( dontdraw < 2 ) { dontdraw = 1; }
28901 26 }
28902
2/2
✓ Branch 0 taken 3606 times.
✓ Branch 1 taken 3048 times.
6654 if(get_bit(quest_rules,qr_FADE))
28903 {
28904
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 1176 times.
3606 if(f < 170)
28905 {
28906
2/2
✓ Branch 0 taken 1540 times.
✓ Branch 1 taken 890 times.
2430 if(f<60)
28907 {
28908 890 draw_screen(tmpscr);
28909 //reuse our static subscreen
28910 890 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
28911 890 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28912 890 }
28913
28914
2/2
✓ Branch 0 taken 2416 times.
✓ Branch 1 taken 14 times.
2430 if(f==60)
28915 {
28916 14 red_shift();
28917 14 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28918 14 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28919 14 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28920
28921
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 14 times.
3598 for(int32_t q=0; q<PAL_SIZE; q++)
28922 {
28923 3584 trans_table2.data[0][q] = q;
28924 3584 trans_table2.data[q][q] = q;
28925 3584 }
28926 14 }
28927
28928
3/4
✓ Branch 0 taken 1540 times.
✓ Branch 1 taken 890 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1540 times.
2430 if(f>=60 && f<=169)
28929 {
28930 1540 draw_screen(tmpscr);
28931 //reuse our static subscreen
28932 1540 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28933 1540 red_shift();
28934
28935 1540 }
28936
28937
3/4
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 1996 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 434 times.
2430 if(f>=139 && f<=169)//fade from red to black
28938 {
28939 434 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
28940 434 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
28941 434 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
28942 434 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
28943
28944
2/2
✓ Branch 0 taken 111104 times.
✓ Branch 1 taken 434 times.
111538 for(int32_t q=0; q<PAL_SIZE; q++)
28945 {
28946 111104 trans_table2.data[0][q] = q;
28947 111104 trans_table2.data[q][q] = q;
28948 111104 }
28949
28950 434 refreshpal=true;
28951 434 }
28952 2430 }
28953 else //f>=170
28954 {
28955
2/2
✓ Branch 0 taken 1162 times.
✓ Branch 1 taken 14 times.
1176 if(f==170)//make Hero grayish
28956 {
28957 14 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
28958
28959
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 14 times.
238 for(int32_t i=CSET(6); i < CSET(7); i++)
28960 {
28961 224 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
28962 224 RAMpal[i] = _RGB(g,g,g);
28963 224 }
28964
28965 14 refreshpal = true;
28966 14 }
28967
28968 //draw only hero. otherwise black layers might cover him.
28969 1176 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
28970 1176 draw(framebuf);
28971 1176 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
28972 }
28973 3606 }
28974 else //!qr_FADE
28975 {
28976
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==58)
28977 {
28978
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 12 times.
1164 for(int32_t i = 0; i < 96; i++)
28979 1152 tmpscr->cset[i] = 3;
28980
28981
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
28982
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
28983
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
28984 194 tmpscr2[j].cset[i] = 3;
28985 12 }
28986
28987
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==59)
28988 {
28989
2/2
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 12 times.
972 for(int32_t i = 96; i < 176; i++)
28990 960 tmpscr->cset[i] = 3;
28991
28992
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
28993
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
28994
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
28995 162 tmpscr2[j].cset[i] = 3;
28996 12 }
28997
28998
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==60)
28999 {
29000
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 for(int32_t i=0; i<176; i++)
29001 {
29002 2112 tmpscr->cset[i] = 2;
29003 2112 }
29004
29005
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 12 times.
84 for(int32_t j=0; j<6; j++)
29006
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 70 times.
74 if(tmpscr->layermap[j]>0)
29007
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
29008 354 tmpscr2[j].cset[i] = 2;
29009
29010
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
29011 {
29012 60 RAMpal[CSET(2)+i] = NESpal(0x17);
29013 60 RAMpal[CSET(2)+i+1] = NESpal(0x16);
29014 60 RAMpal[CSET(2)+i+2] = NESpal(0x26);
29015 60 }
29016
29017 12 refreshpal=true;
29018 12 }
29019
29020
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==139)
29021 12 slide_in_color(0x06);
29022
29023
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==149)
29024 12 slide_in_color(0x07);
29025
29026
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==159)
29027 12 slide_in_color(0x0F);
29028
29029
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==169)
29030 {
29031 12 slide_in_color(0x0F);
29032 12 slide_in_color(0x0F);
29033 12 }
29034
29035
2/2
✓ Branch 0 taken 3036 times.
✓ Branch 1 taken 12 times.
3048 if(f==170)
29036 {
29037
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 12 times.
72 for(int32_t i=1; i<16; i+=3)
29038 {
29039 60 RAMpal[CSET(6)+i] = NESpal(0x10);
29040 60 RAMpal[CSET(6)+i+1] = NESpal(0x30);
29041 60 RAMpal[CSET(6)+i+2] = NESpal(0x00);
29042 60 refreshpal = true;
29043 60 }
29044 12 }
29045
29046
2/2
✓ Branch 0 taken 2028 times.
✓ Branch 1 taken 1020 times.
3048 if(f < 169)
29047 {
29048 2028 draw_screen(tmpscr);
29049 //reuse our static subscreen
29050 2028 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
29051 2028 }
29052 else
29053 {
29054 //draw only hero. otherwise black layers might cover him.
29055 1020 rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
29056 1020 draw(framebuf);
29057 1020 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
29058 }
29059 }
29060 6654 }
29061
29062
2/2
✓ Branch 0 taken 2496 times.
✓ Branch 1 taken 78 times.
2574 else if(f<350)//draw 'GAME OVER' text
29063 {
29064
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2496 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2496 if(get_bit(quest_rules, qr_INSTANT_RESPAWN) && !get_bit(quest_rules, qr_INSTANT_CONTINUE))
29065 {
29066 Quit = qRELOAD;
29067 skipcont = 1;
29068 clear_bitmap(framebuf);
29069 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
29070 }
29071
2/4
✓ Branch 0 taken 2496 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2496 times.
2496 else if(!get_bit(quest_rules, qr_INSTANT_RESPAWN) && get_bit(quest_rules, qr_INSTANT_CONTINUE))
29072 {
29073 Quit = qCONT;
29074 skipcont = 1;
29075 clear_bitmap(framebuf);
29076 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
29077 }
29078 else
29079 {
29080 2496 clear_a5_bmp(rti_infolayer.bitmap);
29081 2496 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
29082 2496 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
29083 2496 textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
29084 }
29085 2496 }
29086 else
29087 {
29088 78 clear_bitmap(framebuf);
29089 }
29090
29091 //SFX... put them all here
29092
4/4
✓ Branch 0 taken 9149 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 26 times.
9228 switch(f)
29093 {
29094 case 0:
29095 27 sfx(getHurtSFX(),pan(x.getInt()));
29096 27 break;
29097 //Death sound.
29098 case 60:
29099 26 sfx(WAV_SPIRAL);
29100 26 break;
29101 //Message sound.
29102 case 194:
29103 26 sfx(WAV_MSG);
29104 26 break;
29105 }
29106 //adv:
29107 9228 advanceframe(true);
29108 9228 ++f;
29109 //if (!player_doscript ) ++f;
29110
2/2
✓ Branch 0 taken 9201 times.
✓ Branch 1 taken 27 times.
18456 }
29111
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 9202 times.
9228 while(f<353 && !Quit);
29112
29113 27 destroy_bitmap(subscrbmp);
29114 27 action=none; FFCore.setHeroAction(none);
29115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if ( dontdraw < 2 ) { dontdraw=0; }
29116 27 }
29117
29118
29119 6 void HeroClass::ganon_intro()
29120 {
29121 /*
29122 ************************
29123 * GANON INTRO SEQUENCE *
29124 ************************
29125 -25 DOT updates
29126 -24 HERO in
29127 0 TRIFORCE overhead - code begins at this point (f == 0)
29128 47 GANON in
29129 58 LIGHT step
29130 68 LIGHT step
29131 78 LIGHT step
29132 255 TRIFORCE out
29133 256 TRIFORCE in
29134 270 TRIFORCE out
29135 271 GANON out, HERO face up
29136 */
29137 6 loaded_guys=true;
29138 6 loaditem();
29139
29140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(game->lvlitems[dlevel]&liBOSS)
29141 {
29142 return;
29143 }
29144
29145 6 dir=down;
29146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( !isSideViewHero() )
29147 {
29148 6 fall = 0; //Fix midair glitch on holding triforce. -Z
29149 6 fakefall = 0;
29150 6 z = 0;
29151 6 fakez = 0;
29152 6 }
29153 6 action=landhold2; FFCore.setHeroAction(landhold2);
29154 6 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
29155 //not good, as this only returns the highest level that Hero possesses. -DD
29156 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
29157
29158
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1446 times.
✓ Branch 2 taken 1446 times.
✓ Branch 3 taken 6 times.
1452 for(int32_t f=0; f<271 && !Quit; f++)
29159 {
29160
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 6 times.
1446 if(f==47)
29161 {
29162 6 music_stop();
29163 6 stop_sfx(WAV_ROAR);
29164 6 sfx(WAV_GASP);
29165 6 sfx(WAV_GANON);
29166 6 int32_t Id=0;
29167
29168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 474 times.
474 for(int32_t i=0; i<eMAXGUYS; i++)
29169 {
29170
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 6 times.
474 if(guysbuf[i].flags2&eneflag_ganon)
29171 {
29172 6 Id=i;
29173 6 break;
29174 }
29175 468 }
29176
29177
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 if(current_item(itype_ring))
29178 {
29179 5 addenemy(160,96,Id,0);
29180 5 }
29181 else
29182 {
29183 1 addenemy(80,32,Id,0);
29184 }
29185 6 }
29186
29187
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 6 times.
1446 if(f==48)
29188 {
29189 6 lighting(true,true); // Hmm. -L
29190 6 f += 30;
29191 6 }
29192
29193 //NES Z1, the triforce vanishes for one frame in two cases
29194 //while still showing Hero's two-handed overhead sprite.
29195 //This should be a Quest Rule for NES Accuracy. -Z
29196
4/4
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1434 times.
1446 if(f==255 || f==270)
29197 {
29198 12 holditem=-1;
29199 12 }
29200
29201
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 6 times.
1446 if(f==256)
29202 {
29203 6 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
29204 6 }
29205
29206 1446 draw_screen(tmpscr);
29207 1446 advanceframe(true);
29208
29209
1/2
✓ Branch 0 taken 1446 times.
✗ Branch 1 not taken.
1446 if(rSbtn())
29210 {
29211 conveyclk=3;
29212 int32_t tmp_subscr_clk = frame;
29213 dosubscr(&QMisc);
29214 newscr_clk += frame - tmp_subscr_clk;
29215 }
29216
29217 1446 }
29218
29219 6 action=none; FFCore.setHeroAction(none);
29220 6 dir=up;
29221
29222
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
29223 2 jukebox(MAXMIDIS-1);
29224 else
29225 4 playLevelMusic();
29226
29227 6 currcset=DMaps[currdmap].color;
29228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (get_bit(quest_rules, qr_GANONINTRO) )
29229 {
29230 6 dointro();
29231 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
29232 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
29233 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
29234 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
29235 6 }
29236 //dointro(); //This is likely what causes Ganon Rooms to repeat the DMap intro.
29237 //I suppose it is to allow the user to make Gaanon rooms have their own dialogue, if they are
29238 //on a different DMap.
29239 //~ Otherwise, why is it here?! -Z
29240
29241
29242 //if ( !(DMaps[currdmap].flags&dmfALWAYSMSG) ) { dointro(); } //This is likely what causes Ganon Rooms to repeat the DMap intro.
29243 //If we try it this way: The dmap flag /always display intro string/ is probably why James had this issue.
29244
29245 //The only fix that I can think of, off the top of me head, is either a QR or a Screen Flag to disable the intro text.
29246 //Users who use that dmap rule should put ganons room on its own DMap! -Z
29247 6 cont_sfx(WAV_ROAR);
29248 6 }
29249
29250 6 void HeroClass::win_game()
29251 {
29252
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 replay_step_comment("win_game");
29253 6 Playing=Paused=false;
29254 6 action=won; FFCore.setHeroAction(won);
29255 6 Quit=qWON;
29256 6 hclk=0;
29257 6 x = 136;
29258
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
6 y = (isdungeon() && currscr<128) ? 75 : 73;
29259 6 z = fakez = fall = fakefall = spins = 0;
29260 6 dir=left;
29261 6 }
29262
29263 11645 void HeroClass::reset_swordcharge()
29264 {
29265 11645 charging=spins=tapping=0;
29266 11645 }
29267
29268 29007 void HeroClass::reset_hookshot()
29269 {
29270
10/12
✓ Branch 0 taken 27075 times.
✓ Branch 1 taken 1932 times.
✓ Branch 2 taken 27068 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 27024 times.
✓ Branch 5 taken 44 times.
✓ Branch 6 taken 27019 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 27019 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 27019 times.
29007 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
29271 {
29272 27019 action=none; FFCore.setHeroAction(none);
29273 27019 }
29274
29275 29007 hookshot_frozen=false;
29276 29007 hookshot_used=false;
29277 29007 pull_hero=false;
29278 29007 hs_fix=false;
29279 29007 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
29280 29007 switch_hooked = false;
29281
2/2
✓ Branch 0 taken 29006 times.
✓ Branch 1 taken 1 times.
29007 if(switching_object)
29282 1 switching_object->switch_hooked = false;
29283 29007 switching_object = NULL;
29284 29007 hooked_combopos = -1;
29285 29007 switchhook_cost_item = -1;
29286 29007 hooked_layerbits = 0;
29287
2/2
✓ Branch 0 taken 203049 times.
✓ Branch 1 taken 29007 times.
232056 for(auto q = 0; q < 7; ++q)
29288 203049 hooked_undercombos[q] = -1;
29289 29007 Lwpns.del(Lwpns.idFirst(wHSHandle));
29290 29007 Lwpns.del(Lwpns.idFirst(wHookshot));
29291 29007 chainlinks.clear();
29292
2/2
✓ Branch 0 taken 2474 times.
✓ Branch 1 taken 26533 times.
29007 int32_t index=directItem>-1 ? directItem : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
29293 29007 hs_switcher = false;
29294
29295
2/2
✓ Branch 0 taken 23164 times.
✓ Branch 1 taken 5843 times.
29007 if(index>=0)
29296 {
29297 5843 stop_sfx(itemsbuf[index].usesound);
29298 5843 }
29299
29300 29007 hs_xdist=0;
29301 29007 hs_ydist=0;
29302 29007 }
29303
29304
29305 3727170 bool HeroClass::can_deploy_ladder()
29306 {
29307
2/2
✓ Branch 0 taken 1007181 times.
✓ Branch 1 taken 2719989 times.
5814202 bool ladderallowed = ((!get_bit(quest_rules,qr_LADDERANYWHERE) && tmpscr->flags&fLADDER) || isdungeon()
29308
4/4
✓ Branch 0 taken 1272621 times.
✓ Branch 1 taken 2087032 times.
✓ Branch 2 taken 322735 times.
✓ Branch 3 taken 1764297 times.
2719989 || (get_bit(quest_rules,qr_LADDERANYWHERE) && !(tmpscr->flags&fLADDER)));
29309
8/10
✓ Branch 0 taken 1433161 times.
✓ Branch 1 taken 2933673 times.
✓ Branch 2 taken 1143455 times.
✓ Branch 3 taken 289706 times.
✓ Branch 4 taken 1143386 times.
✓ Branch 5 taken 69 times.
✓ Branch 6 taken 1143386 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1143386 times.
5510220 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 &&
29310
2/2
✓ Branch 0 taken 1122706 times.
✓ Branch 1 taken 20680 times.
1143386 (!isSideViewHero() || on_sideview_solid_oldpos(x,y,old_x,old_y)));
29311 }
29312
29313 4398028 void HeroClass::reset_ladder()
29314 {
29315 4398028 ladderx=laddery=0;
29316 4398028 }
29317
29318 bool is_conveyor(int32_t type);
29319 int32_t get_conveyor(int32_t x, int32_t y);
29320
29321 5152186 void HeroClass::check_conveyor()
29322 {
29323 5152186 ++newconveyorclk;
29324
1/2
✓ Branch 0 taken 5152186 times.
✗ Branch 1 not taken.
5152186 if (newconveyorclk < 0) newconveyorclk = 0;
29325
29326
14/18
✓ Branch 0 taken 5152186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5152186 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5151482 times.
✓ Branch 5 taken 704 times.
✓ Branch 6 taken 5151482 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5151482 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5149233 times.
✓ Branch 11 taken 2249 times.
✓ Branch 12 taken 5148723 times.
✓ Branch 13 taken 510 times.
✓ Branch 14 taken 5145454 times.
✓ Branch 15 taken 3269 times.
✓ Branch 16 taken 5145454 times.
✓ Branch 17 taken 3269 times.
5152186 if(action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||((z>0||fakez>0) && !(tmpscr->flags2&fAIRCOMBOS)))
29327 {
29328 6732 is_conveyor_stunned = 0;
29329 6732 return;
29330 }
29331
29332 5145454 WalkflagInfo info;
29333 int32_t xoff,yoff;
29334 5145454 zfix deltax(0), deltay(0);
29335 5145454 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
29336
2/2
✓ Branch 0 taken 3433645 times.
✓ Branch 1 taken 1711809 times.
5145454 if(cmbid < 0)
29337 {
29338
2/2
✓ Branch 0 taken 3432934 times.
✓ Branch 1 taken 711 times.
3433645 if (conveyclk <= 0) is_on_conveyor=false;
29339 3433645 return;
29340 }
29341 1711809 newcombo const* cmb = &combobuf[cmbid];
29342 1711809 auto pos = COMBOPOS(x+7,y+(bigHitbox?8:12));
29343 1711809 bool custom_spd = (cmb->usrflags&cflag2);
29344
3/4
✓ Branch 0 taken 1710981 times.
✓ Branch 1 taken 828 times.
✓ Branch 2 taken 1710981 times.
✗ Branch 3 not taken.
1711809 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
29345 {
29346 1711809 int32_t ctype=cmb->type;
29347
3/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 1710981 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 828 times.
1711809 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
29348
3/4
✓ Branch 0 taken 828 times.
✓ Branch 1 taken 1710981 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 828 times.
1711809 if(custom_spd && (newconveyorclk % rate)) return;
29349
3/4
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 1711134 times.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
1711809 if((cmb->usrflags&cflag5) && HasHeavyBoots())
29350 return;
29351 1711809 is_on_conveyor=false;
29352 1711809 is_conveyor_stunned=0;
29353
29354 1711809 deltax=combo_class_buf[ctype].conveyor_x_speed;
29355 1711809 deltay=combo_class_buf[ctype].conveyor_y_speed;
29356
29357
3/4
✓ Branch 0 taken 1371 times.
✓ Branch 1 taken 1710438 times.
✓ Branch 2 taken 1371 times.
✗ Branch 3 not taken.
1711809 if (is_conveyor(ctype) && custom_spd)
29358 {
29359 deltax = zslongToFix(cmb->attributes[0]);
29360 deltay = zslongToFix(cmb->attributes[1]);
29361 }
29362
29363
8/8
✓ Branch 0 taken 1711085 times.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 1710438 times.
✓ Branch 3 taken 647 times.
✓ Branch 4 taken 86205 times.
✓ Branch 5 taken 1624233 times.
✓ Branch 6 taken 42696 times.
✓ Branch 7 taken 43509 times.
1711809 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(x,y,old_x,old_y)))
29364 {
29365 43509 cmbid = MAPCOMBO(x+8,y+16);
29366 43509 cmb = &combobuf[cmbid];
29367 43509 custom_spd = cmb->usrflags&cflag2;
29368 43509 ctype=(cmb->type);
29369 43509 deltax=combo_class_buf[ctype].conveyor_x_speed;
29370 43509 deltay=combo_class_buf[ctype].conveyor_y_speed;
29371
2/4
✓ Branch 0 taken 43509 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43509 times.
✗ Branch 3 not taken.
43509 if ((deltax != 0 || deltay != 0) && custom_spd)
29372 {
29373 deltax = zslongToFix(cmb->attributes[0]);
29374 deltay = zslongToFix(cmb->attributes[1]);
29375 }
29376 43509 }
29377
29378
4/4
✓ Branch 0 taken 1711085 times.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 647 times.
✓ Branch 3 taken 1710438 times.
1711809 if(deltax!=0||deltay!=0)
29379 {
29380 1371 is_on_conveyor=true;
29381 1371 }
29382 1710438 else return;
29383
29384 1371 bool movedx = false, movedy = false;
29385
1/2
✓ Branch 0 taken 1371 times.
✗ Branch 1 not taken.
1371 if(cmb->usrflags&cflag4) //Smart corners
29386 {
29387 if(deltay<0)
29388 {
29389 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29390 execute(info);
29391
29392 if(!info.isUnwalkable())
29393 {
29394 movedy = true;
29395 zfix step(0);
29396
29397 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29398 {
29399 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29400 {
29401 yoff=int32_t(y-step)&7;
29402
29403 if(!yoff) break;
29404
29405 step++;
29406 }
29407 }
29408 else
29409 {
29410 step=abs(deltay);
29411 }
29412
29413 y=y-step;
29414 hs_starty-=step.getInt();
29415
29416 for(int32_t j=0; j<chainlinks.Count(); j++)
29417 {
29418 chainlinks.spr(j)->y-=step;
29419 }
29420
29421 if(Lwpns.idFirst(wHookshot)>-1)
29422 {
29423 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29424 }
29425
29426 if(Lwpns.idFirst(wHSHandle)>-1)
29427 {
29428 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29429 }
29430 }
29431 }
29432 else if(deltay>0)
29433 {
29434 info = walkflag(x,y+15+2,2,down);
29435 execute(info);
29436
29437 if(!info.isUnwalkable())
29438 {
29439 movedy = true;
29440 zfix step(0);
29441
29442 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29443 {
29444 while(step<abs(deltay))
29445 {
29446 yoff=int32_t(y+step)&7;
29447
29448 if(!yoff) break;
29449
29450 step++;
29451 }
29452 }
29453 else
29454 {
29455 step=abs(deltay);
29456 }
29457
29458 y=y+step;
29459 hs_starty+=step.getInt();
29460
29461 for(int32_t j=0; j<chainlinks.Count(); j++)
29462 {
29463 chainlinks.spr(j)->y+=step;
29464 }
29465
29466 if(Lwpns.idFirst(wHookshot)>-1)
29467 {
29468 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29469 }
29470
29471 if(Lwpns.idFirst(wHSHandle)>-1)
29472 {
29473 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29474 }
29475 }
29476 }
29477
29478 if(deltax<0)
29479 {
29480 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29481 execute(info);
29482
29483 if(!info.isUnwalkable())
29484 {
29485 movedx = true;
29486 zfix step(0);
29487
29488 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29489 {
29490 while(step<abs(deltax))
29491 {
29492 xoff=int32_t(x-step)&7;
29493
29494 if(!xoff) break;
29495
29496 step++;
29497 }
29498 }
29499 else
29500 {
29501 step=abs(deltax);
29502 }
29503
29504 x=x-step;
29505 hs_startx-=step.getInt();
29506
29507 for(int32_t j=0; j<chainlinks.Count(); j++)
29508 {
29509 chainlinks.spr(j)->x-=step;
29510 }
29511
29512 if(Lwpns.idFirst(wHookshot)>-1)
29513 {
29514 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29515 }
29516
29517 if(Lwpns.idFirst(wHSHandle)>-1)
29518 {
29519 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29520 }
29521 }
29522 }
29523 else if(deltax>0)
29524 {
29525 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29526 execute(info);
29527
29528 if(!info.isUnwalkable())
29529 {
29530 movedx = true;
29531 zfix step(0);
29532
29533 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29534 {
29535 while(step<abs(deltax))
29536 {
29537 xoff=int32_t(x+step)&7;
29538
29539 if(!xoff) break;
29540
29541 step++;
29542 }
29543 }
29544 else
29545 {
29546 step=abs(deltax);
29547 }
29548
29549 x=x+step;
29550 hs_startx+=step.getInt();
29551
29552 for(int32_t j=0; j<chainlinks.Count(); j++)
29553 {
29554 chainlinks.spr(j)->x+=step;
29555 }
29556
29557 if(Lwpns.idFirst(wHookshot)>-1)
29558 {
29559 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29560 }
29561
29562 if(Lwpns.idFirst(wHSHandle)>-1)
29563 {
29564 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29565 }
29566 }
29567 }
29568 if(deltax && !movedx)
29569 y = COMBOY(pos);
29570 if(deltay && !movedy)
29571 x = COMBOX(pos);
29572 }
29573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
1371 if(!movedy)
29574 {
29575
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 1189 times.
1371 if(deltay<0)
29576 {
29577 182 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
29578 182 execute(info);
29579
29580
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 156 times.
182 if(!info.isUnwalkable())
29581 {
29582 156 movedy = true;
29583 156 zfix step(0);
29584
29585
9/10
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 90 times.
✓ Branch 4 taken 11 times.
✓ Branch 5 taken 55 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 5 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 6 times.
156 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29586 {
29587
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11 times.
16 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
29588 {
29589 11 yoff=int32_t(y-step)&7;
29590
29591
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
11 if(!yoff) break;
29592
29593 10 step++;
29594 }
29595 6 }
29596 else
29597 {
29598 150 step=abs(deltay);
29599 }
29600
29601 156 y=y-step;
29602 156 hs_starty-=step.getInt();
29603
29604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
156 for(int32_t j=0; j<chainlinks.Count(); j++)
29605 {
29606 chainlinks.spr(j)->y-=step;
29607 }
29608
29609
1/2
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
156 if(Lwpns.idFirst(wHookshot)>-1)
29610 {
29611 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
29612 }
29613
29614
1/2
✓ Branch 0 taken 156 times.
✗ Branch 1 not taken.
156 if(Lwpns.idFirst(wHSHandle)>-1)
29615 {
29616 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
29617 }
29618 156 }
29619 26 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
29620 182 }
29621
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 465 times.
1189 else if(deltay>0)
29622 {
29623 465 info = walkflag(x,y+15+2,2,down);
29624 465 execute(info);
29625
29626
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 334 times.
465 if(!info.isUnwalkable())
29627 {
29628 334 movedy = true;
29629 334 zfix step(0);
29630
29631
8/10
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 86 times.
✓ Branch 3 taken 248 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 51 times.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 35 times.
334 if((DrunkRight()||DrunkLeft())&&dir!=left&&dir!=right&&!(diagonalMovement||NO_GRIDLOCK))
29632 {
29633
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 62 times.
87 while(step<abs(deltay))
29634 {
29635 62 yoff=int32_t(y+step)&7;
29636
29637
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 10 times.
62 if(!yoff) break;
29638
29639 52 step++;
29640 }
29641 35 }
29642 else
29643 {
29644 299 step=abs(deltay);
29645 }
29646
29647 334 y=y+step;
29648 334 hs_starty+=step.getInt();
29649
29650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 for(int32_t j=0; j<chainlinks.Count(); j++)
29651 {
29652 chainlinks.spr(j)->y+=step;
29653 }
29654
29655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(Lwpns.idFirst(wHookshot)>-1)
29656 {
29657 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
29658 }
29659
29660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 if(Lwpns.idFirst(wHSHandle)>-1)
29661 {
29662 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
29663 }
29664 334 }
29665 131 else checkdamagecombos(x,y+15);
29666 465 }
29667 1371 }
29668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
1371 if(!movedx)
29669 {
29670
2/2
✓ Branch 0 taken 457 times.
✓ Branch 1 taken 914 times.
1371 if(deltax<0)
29671 {
29672 457 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
29673 457 execute(info);
29674
29675
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 292 times.
457 if(!info.isUnwalkable())
29676 {
29677 292 movedx = true;
29678 292 zfix step(0);
29679
29680
8/10
✓ Branch 0 taken 251 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 241 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14 times.
292 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29681 {
29682
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 24 times.
34 while(step<abs(deltax))
29683 {
29684 24 xoff=int32_t(x-step)&7;
29685
29686
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
24 if(!xoff) break;
29687
29688 20 step++;
29689 }
29690 14 }
29691 else
29692 {
29693 278 step=abs(deltax);
29694 }
29695
29696 292 x=x-step;
29697 292 hs_startx-=step.getInt();
29698
29699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
292 for(int32_t j=0; j<chainlinks.Count(); j++)
29700 {
29701 chainlinks.spr(j)->x-=step;
29702 }
29703
29704
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if(Lwpns.idFirst(wHookshot)>-1)
29705 {
29706 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
29707 }
29708
29709
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if(Lwpns.idFirst(wHSHandle)>-1)
29710 {
29711 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
29712 }
29713 292 }
29714 165 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
29715 457 }
29716
2/2
✓ Branch 0 taken 647 times.
✓ Branch 1 taken 267 times.
914 else if(deltax>0)
29717 {
29718 267 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
29719 267 execute(info);
29720
29721
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 264 times.
267 if(!info.isUnwalkable())
29722 {
29723 264 movedx = true;
29724 264 zfix step(0);
29725
29726
8/10
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 208 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 31 times.
✓ Branch 6 taken 25 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
264 if((DrunkUp()||DrunkDown())&&dir!=up&&dir!=down&&!(diagonalMovement||NO_GRIDLOCK))
29727 {
29728
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 47 times.
67 while(step<abs(deltax))
29729 {
29730 47 xoff=int32_t(x+step)&7;
29731
29732
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5 times.
47 if(!xoff) break;
29733
29734 42 step++;
29735 }
29736 25 }
29737 else
29738 {
29739 239 step=abs(deltax);
29740 }
29741
29742 264 x=x+step;
29743 264 hs_startx+=step.getInt();
29744
29745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 for(int32_t j=0; j<chainlinks.Count(); j++)
29746 {
29747 chainlinks.spr(j)->x+=step;
29748 }
29749
29750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(Lwpns.idFirst(wHookshot)>-1)
29751 {
29752 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
29753 }
29754
29755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if(Lwpns.idFirst(wHSHandle)>-1)
29756 {
29757 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
29758 }
29759 264 }
29760 3 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
29761 267 }
29762 1371 }
29763
4/4
✓ Branch 0 taken 815 times.
✓ Branch 1 taken 556 times.
✓ Branch 2 taken 490 times.
✓ Branch 3 taken 325 times.
1371 if(movedx || movedy)
29764 {
29765
1/2
✓ Branch 0 taken 1046 times.
✗ Branch 1 not taken.
1046 if(cmb->usrflags&cflag1)
29766 is_conveyor_stunned = rate;
29767
1/2
✓ Branch 0 taken 1046 times.
✗ Branch 1 not taken.
1046 if(cmb->usrflags&cflag3)
29768 {
29769 if(abs(deltax) > abs(deltay))
29770 dir = (deltax > 0) ? right : left;
29771 else dir = (deltay > 0) ? down : up;
29772 }
29773 1046 }
29774 1371 }
29775 5152186 }
29776
29777 void HeroClass::setNayrusLoveShieldClk(int32_t newclk)
29778 {
29779 NayrusLoveShieldClk=newclk;
29780
29781 if(decorations.idCount(dNAYRUSLOVESHIELD)==0)
29782 {
29783 decoration *dec;
29784 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29785 decorations.spr(decorations.Count()-1)->misc=0;
29786 decorations.add(new dNayrusLoveShield(HeroX(), HeroY(), dNAYRUSLOVESHIELD, 0));
29787 dec=(decoration *)decorations.spr(decorations.Count()-1);
29788 decorations.spr(decorations.Count()-1)->misc=1;
29789 }
29790 }
29791
29792 10471 int32_t HeroClass::getNayrusLoveShieldClk()
29793 {
29794 10471 return NayrusLoveShieldClk;
29795 }
29796
29797 21 int32_t HeroClass::getHoverClk()
29798 {
29799 21 return hoverclk;
29800 }
29801
29802 6786515 int32_t HeroClass::getHoldClk()
29803 {
29804 6786515 return holdclk;
29805 }
29806
29807 4203173 int32_t HeroClass::getLastLensID(){
29808 4203173 return last_lens_id;
29809 }
29810
29811 209 void HeroClass::setLastLensID(int32_t p_item){
29812 209 last_lens_id = p_item;
29813 209 }
29814
29815 42803812 bool HeroClass::getOnSideviewLadder()
29816 {
29817 42803812 return on_sideview_ladder;
29818 }
29819
29820 71 void HeroClass::setOnSideviewLadder(bool val)
29821 {
29822
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 5 times.
71 if(val)
29823 {
29824 5 fall = fakefall = hoverclk = jumping = 0;
29825 5 hoverflags = 0;
29826 5 inair = false;
29827 5 }
29828 71 on_sideview_ladder = val;
29829 71 }
29830
29831 1505794 bool HeroClass::canSideviewLadder(bool down)
29832 {
29833
2/2
✓ Branch 0 taken 1470155 times.
✓ Branch 1 taken 35639 times.
1505794 if(!isSideViewHero()) return false;
29834
2/2
✓ Branch 0 taken 22433 times.
✓ Branch 1 taken 13206 times.
35639 if(jumping < 0) return false;
29835
3/4
✓ Branch 0 taken 9387 times.
✓ Branch 1 taken 13046 times.
✓ Branch 2 taken 9387 times.
✗ Branch 3 not taken.
22433 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29836 {
29837 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29838 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
29839 }
29840 //Are you presently able to climb a sideview ladder?
29841 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29842 //y+0 checks your top-half for large hitbox; y+8 for small
29843 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29844 //y+16 check is for going down onto a ladder you are standing on.
29845
2/2
✓ Branch 0 taken 22155 times.
✓ Branch 1 taken 278 times.
44517 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
29846
4/4
✓ Branch 0 taken 22084 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 22000 times.
✓ Branch 3 taken 84 times.
22155 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
29847
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22000 times.
✓ Branch 2 taken 12613 times.
✓ Branch 3 taken 9387 times.
✓ Branch 4 taken 9387 times.
✗ Branch 5 not taken.
31387 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
29848 1505794 }
29849
29850 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
29851 {
29852 if(!isSideViewHero()) return false;
29853 if(jumping < 0) return false;
29854 if(down && get_bit(quest_rules, qr_DOWN_DOESNT_GRAB_LADDERS))
29855 {
29856 bool onSolid = on_sideview_solid_oldpos(x,y,old_x,old_y,true);
29857 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
29858 }
29859 //Are you presently able to climb a sideview ladder?
29860 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
29861 //y+0 checks your top-half for large hitbox; y+8 for small
29862 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
29863 //y+16 check is for going down onto a ladder you are standing on.
29864 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
29865 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
29866 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
29867 }
29868
29869 3208463 void HeroClass::execute(HeroClass::WalkflagInfo info)
29870 {
29871 3208463 int32_t flags = info.getFlags();
29872
29873
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3207851 times.
3208463 if(flags & WalkflagInfo::CLEARILSWIM)
29874 612 ilswim =false;
29875
2/2
✓ Branch 0 taken 3207543 times.
✓ Branch 1 taken 308 times.
3207851 else if(flags & WalkflagInfo::SETILSWIM)
29876 308 ilswim = true;
29877
29878
1/2
✓ Branch 0 taken 3208463 times.
✗ Branch 1 not taken.
3208463 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
29879 {
29880 charging = 0;
29881 attackclk = 0;
29882 }
29883
29884
1/2
✓ Branch 0 taken 3208463 times.
✗ Branch 1 not taken.
3208463 if(flags & WalkflagInfo::SETDIR)
29885 {
29886 dir = info.getDir();
29887 }
29888
29889
2/2
✓ Branch 0 taken 3208017 times.
✓ Branch 1 taken 446 times.
3208463 if(flags & WalkflagInfo::SETHOPCLK)
29890 {
29891 446 hopclk = info.getHopClk();
29892 446 }
29893
29894
2/2
✓ Branch 0 taken 3208240 times.
✓ Branch 1 taken 223 times.
3208463 if(flags & WalkflagInfo::SETHOPDIR)
29895 {
29896 223 hopdir = info.getHopDir();
29897 223 }
29898
29899 3208463 }
29900
29901 6825467 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
29902 {
29903 6825467 HeroClass::WalkflagInfo ret;
29904 6825467 ret.newhopclk = newhopclk;
29905 6825467 ret.newdir = newdir;
29906
2/2
✓ Branch 0 taken 5668310 times.
✓ Branch 1 taken 1157157 times.
6825467 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29907
29908 6825467 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
29909 6825467 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
29910 6825467 ret.flags = flags1 | flags2;
29911 6825467 return ret;
29912 }
29913
29914 45832 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
29915 {
29916 45832 HeroClass::WalkflagInfo ret;
29917 45832 ret.newhopclk = newhopclk;
29918 45832 ret.newdir = newdir;
29919
1/2
✓ Branch 0 taken 45832 times.
✗ Branch 1 not taken.
45832 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
29920
29921 45832 ret.flags = flags & other.flags;
29922 45832 return ret;
29923 }
29924
29925 45832 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
29926 {
29927 45832 HeroClass::WalkflagInfo ret;
29928 45832 ret.newhopclk = newhopclk;
29929 45832 ret.newdir = newdir;
29930 45832 ret.newhopdir = newhopdir;
29931
29932 45832 ret.flags = flags ^ UNWALKABLE;
29933 45832 return ret;
29934 }
29935
29936 void HeroClass::explode(int32_t type)
29937 {
29938 static int32_t tempx, tempy;
29939 static byte herotilebuf[256];
29940 int32_t ltile=0;
29941 int32_t lflip=0;
29942 bool shieldModify=true;
29943 unpack_tile(newtilebuf, tile, flip, true);
29944 memcpy(herotilebuf, unpackbuf, 256);
29945 tempx=Hero.getX();
29946 tempy=Hero.getY();
29947 for(int32_t i=0; i<16; ++i)
29948 {
29949 for(int32_t j=0; j<16; ++j)
29950 {
29951 if(herotilebuf[i*16+j])
29952 {
29953 if(type==0) // Twilight
29954 {
29955 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 0, 0, (zc_oldrand()%8)+i*4));
29956 int32_t k=particles.Count()-1;
29957 particle *p = (particles.at(k));
29958 p->step=3;
29959 }
29960 else if(type ==1) // Sands of Hours
29961 {
29962 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 1, 2, (zc_oldrand()%16)+i*2));
29963 int32_t k=particles.Count()-1;
29964 particle *p = (particles.at(k));
29965 p->step=4;
29966
29967 if(zc_oldrand()%10 < 2)
29968 {
29969 p->color=1;
29970 p->cset=0;
29971 }
29972 }
29973 else
29974 {
29975 particles.add(new pFaroresWindDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 5, 6, herotilebuf[i*16+j], zc_oldrand()%96));
29976
29977 int32_t k=particles.Count()-1;
29978 particle *p = (particles.at(k));
29979 p->angular=true;
29980 p->angle=zc_oldrand();
29981 p->step=(((double)j)/8);
29982 p->yofs=Hero.getYOfs();
29983 }
29984 }
29985 }
29986 }
29987 }
29988
29989 853 void HeroClass::SetSwim()
29990 {
29991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 853 times.
853 if (CanSideSwim())
29992 {
29993 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
29994 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
29995 if (get_bit(quest_rules,qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
29996 }
29997 853 else {action=swimming; FFCore.setHeroAction(swimming);}
29998 853 }
29999
30000 50617 void HeroClass::SetAttack()
30001 {
30002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50617 times.
50617 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
30003 50617 else {action=attacking; FFCore.setHeroAction(attacking);}
30004 50617 }
30005
30006 42701110 bool HeroClass::IsSideSwim()
30007 {
30008
6/12
✓ Branch 0 taken 42701110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42701110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42701110 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42701110 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42701110 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 42701110 times.
42701110 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
30009 }
30010
30011 1141422 bool HeroClass::CanSideSwim()
30012 {
30013
1/2
✓ Branch 0 taken 1141422 times.
✗ Branch 1 not taken.
1141422 return (isSideViewHero() && get_bit(quest_rules,qr_SIDESWIM));
30014 }
30015
30016 4086346 int32_t HeroClass::getTileModifier()
30017 {
30018 4086346 return item_tile_mod() + bunny_tile_mod();
30019 }
30020 void HeroClass::setImmortal(int32_t nimmortal)
30021 {
30022 immortal = nimmortal;
30023 }
30024 void HeroClass::kill(bool bypassFairy)
30025 {
30026 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
30027 }
30028 10321743 bool HeroClass::sideview_mode() const
30029 {
30030
3/4
✓ Branch 0 taken 522397 times.
✓ Branch 1 taken 9799346 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 522397 times.
10321743 return isSideViewHero() && (moveflags & FLAG_OBEYS_GRAV) && !toogam;
30031 }
30032 13071 bool HeroClass::is_unpushable() const
30033 {
30034 13071 return toogam;
30035 }
30036 /*** end of hero.cpp ***/
30037
30038
30039
30040
30041